<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>spharm.spharm</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th bgcolor="#70b0f0" class="navbar-select"
          >&nbsp;&nbsp;&nbsp;Home&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        Package&nbsp;spharm ::
        Module&nbsp;spharm
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="spharm.spharm-module.html">Module spharm.spharm</a></h1>
<pre class="py-src">
<a name="L1"></a><tt class="py-lineno">   1</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L2"></a><tt class="py-lineno">   2</tt>  <tt class="py-line"><tt class="py-docstring">Introduction</tt> </tt>
<a name="L3"></a><tt class="py-lineno">   3</tt>  <tt class="py-line"><tt class="py-docstring">============</tt> </tt>
<a name="L4"></a><tt class="py-lineno">   4</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L5"></a><tt class="py-lineno">   5</tt>  <tt class="py-line"><tt class="py-docstring">This module provides a python interface to the NCAR</tt> </tt>
<a name="L6"></a><tt class="py-lineno">   6</tt>  <tt class="py-line"><tt class="py-docstring">U{SPHEREPACK&lt;https://www2.cisl.ucar.edu/resources/legacy/spherepack&gt;} library.</tt> </tt>
<a name="L7"></a><tt class="py-lineno">   7</tt>  <tt class="py-line"><tt class="py-docstring">It is not a one-to-one wrapper for the SPHEREPACK routines, rather</tt> </tt>
<a name="L8"></a><tt class="py-lineno">   8</tt>  <tt class="py-line"><tt class="py-docstring">it provides a simple interface oriented toward working with</tt> </tt>
<a name="L9"></a><tt class="py-lineno">   9</tt>  <tt class="py-line"><tt class="py-docstring">atmospheric general circulation model (GCM) data.</tt> </tt>
<a name="L10"></a><tt class="py-lineno">  10</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L11"></a><tt class="py-lineno">  11</tt>  <tt class="py-line"><tt class="py-docstring">Requirements</tt> </tt>
<a name="L12"></a><tt class="py-lineno">  12</tt>  <tt class="py-line"><tt class="py-docstring">============</tt> </tt>
<a name="L13"></a><tt class="py-lineno">  13</tt>  <tt class="py-line"><tt class="py-docstring"> - U{numpy&lt;http://numeric.scipy.org&gt;}, and a fortran compiler</tt> </tt>
<a name="L14"></a><tt class="py-lineno">  14</tt>  <tt class="py-line"><tt class="py-docstring"> supported by numpy.f2py.</tt> </tt>
<a name="L15"></a><tt class="py-lineno">  15</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L16"></a><tt class="py-lineno">  16</tt>  <tt class="py-line"><tt class="py-docstring">Installation</tt> </tt>
<a name="L17"></a><tt class="py-lineno">  17</tt>  <tt class="py-line"><tt class="py-docstring">============</tt> </tt>
<a name="L18"></a><tt class="py-lineno">  18</tt>  <tt class="py-line"><tt class="py-docstring"> - U{Download&lt;http://code.google.com/p/pyspharm/downloads/list&gt;} module source,</tt> </tt>
<a name="L19"></a><tt class="py-lineno">  19</tt>  <tt class="py-line"><tt class="py-docstring"> untar.</tt> </tt>
<a name="L20"></a><tt class="py-lineno">  20</tt>  <tt class="py-line"><tt class="py-docstring"> - run C{python setup.py install} (as root if necessary).</tt> </tt>
<a name="L21"></a><tt class="py-lineno">  21</tt>  <tt class="py-line"><tt class="py-docstring"> The SPHERPACK fortran source files will be downloaded automatically by the</tt> </tt>
<a name="L22"></a><tt class="py-lineno">  22</tt>  <tt class="py-line"><tt class="py-docstring"> setup.py script, since the SPHEREPACK license prohibits redistribution.</tt> </tt>
<a name="L23"></a><tt class="py-lineno">  23</tt>  <tt class="py-line"><tt class="py-docstring"> To specify the fortran compiler to use (e.g. g95) run</tt> </tt>
<a name="L24"></a><tt class="py-lineno">  24</tt>  <tt class="py-line"><tt class="py-docstring"> C{python setup.py config_fc --fcompiler=g95 install}. C{f2py -c --help-fcompiler}</tt> </tt>
<a name="L25"></a><tt class="py-lineno">  25</tt>  <tt class="py-line"><tt class="py-docstring"> will show you what fortran compilers are available.</tt> </tt>
<a name="L26"></a><tt class="py-lineno">  26</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L27"></a><tt class="py-lineno">  27</tt>  <tt class="py-line"><tt class="py-docstring">Usage</tt> </tt>
<a name="L28"></a><tt class="py-lineno">  28</tt>  <tt class="py-line"><tt class="py-docstring">=====</tt> </tt>
<a name="L29"></a><tt class="py-lineno">  29</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L30"></a><tt class="py-lineno">  30</tt>  <tt class="py-line"><tt class="py-docstring">&gt;&gt;&gt; import spharm</tt> </tt>
<a name="L31"></a><tt class="py-lineno">  31</tt>  <tt class="py-line"><tt class="py-docstring">&gt;&gt;&gt; x=spharm.Spharmt(144,72,rsphere=8e6,gridtype='gaussian',legfunc='computed')</tt> </tt>
<a name="L32"></a><tt class="py-lineno">  32</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L33"></a><tt class="py-lineno">  33</tt>  <tt class="py-line"><tt class="py-docstring">creates a class instance for spherical harmonic calculations on a 144x72</tt> </tt>
<a name="L34"></a><tt class="py-lineno">  34</tt>  <tt class="py-line"><tt class="py-docstring">gaussian grid on a sphere with radius 8000 km. The associated legendre</tt> </tt>
<a name="L35"></a><tt class="py-lineno">  35</tt>  <tt class="py-line"><tt class="py-docstring">functions are recomputed on the fly (instead of pre-computed and stored).</tt> </tt>
<a name="L36"></a><tt class="py-lineno">  36</tt>  <tt class="py-line"><tt class="py-docstring">Default values of rsphere, gridtype and legfunc are 6.3712e6, 'regular'</tt> </tt>
<a name="L37"></a><tt class="py-lineno">  37</tt>  <tt class="py-line"><tt class="py-docstring">and 'stored'. Real-world examples are included in the source distribution.</tt> </tt>
<a name="L38"></a><tt class="py-lineno">  38</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L39"></a><tt class="py-lineno">  39</tt>  <tt class="py-line"><tt class="py-docstring">Class methods</tt> </tt>
<a name="L40"></a><tt class="py-lineno">  40</tt>  <tt class="py-line"><tt class="py-docstring">=============</tt> </tt>
<a name="L41"></a><tt class="py-lineno">  41</tt>  <tt class="py-line"><tt class="py-docstring"> - grdtospec: grid to spectral transform (spherical harmonic analysis).</tt> </tt>
<a name="L42"></a><tt class="py-lineno">  42</tt>  <tt class="py-line"><tt class="py-docstring"> - spectogrd: spectral to grid transform (spherical harmonic synthesis).</tt> </tt>
<a name="L43"></a><tt class="py-lineno">  43</tt>  <tt class="py-line"><tt class="py-docstring"> - getuv:  compute u and v winds from spectral coefficients of vorticity</tt> </tt>
<a name="L44"></a><tt class="py-lineno">  44</tt>  <tt class="py-line"><tt class="py-docstring"> and divergence.</tt> </tt>
<a name="L45"></a><tt class="py-lineno">  45</tt>  <tt class="py-line"><tt class="py-docstring"> - getvrtdivspec: get spectral coefficients of vorticity and divergence</tt> </tt>
<a name="L46"></a><tt class="py-lineno">  46</tt>  <tt class="py-line"><tt class="py-docstring"> from u and v winds.</tt> </tt>
<a name="L47"></a><tt class="py-lineno">  47</tt>  <tt class="py-line"><tt class="py-docstring"> - getgrad: compute the vector gradient given spectral coefficients.</tt> </tt>
<a name="L48"></a><tt class="py-lineno">  48</tt>  <tt class="py-line"><tt class="py-docstring"> - getpsichi: compute streamfunction and velocity potential from winds.</tt> </tt>
<a name="L49"></a><tt class="py-lineno">  49</tt>  <tt class="py-line"><tt class="py-docstring"> - specsmooth:  isotropic spectral smoothing.</tt> </tt>
<a name="L50"></a><tt class="py-lineno">  50</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L51"></a><tt class="py-lineno">  51</tt>  <tt class="py-line"><tt class="py-docstring">Functions</tt> </tt>
<a name="L52"></a><tt class="py-lineno">  52</tt>  <tt class="py-line"><tt class="py-docstring">=========</tt> </tt>
<a name="L53"></a><tt class="py-lineno">  53</tt>  <tt class="py-line"><tt class="py-docstring"> - regrid:  spectral re-gridding, with optional spectral smoothing and/or</tt> </tt>
<a name="L54"></a><tt class="py-lineno">  54</tt>  <tt class="py-line"><tt class="py-docstring"> truncation.</tt> </tt>
<a name="L55"></a><tt class="py-lineno">  55</tt>  <tt class="py-line"><tt class="py-docstring"> - gaussian_lats_wts: compute gaussian latitudes and weights.</tt> </tt>
<a name="L56"></a><tt class="py-lineno">  56</tt>  <tt class="py-line"><tt class="py-docstring"> - getspecindx: compute indices of zonal wavenumber and degree</tt> </tt>
<a name="L57"></a><tt class="py-lineno">  57</tt>  <tt class="py-line"><tt class="py-docstring"> for complex spherical harmonic coefficients.</tt> </tt>
<a name="L58"></a><tt class="py-lineno">  58</tt>  <tt class="py-line"><tt class="py-docstring"> - legendre: compute associated legendre functions.</tt> </tt>
<a name="L59"></a><tt class="py-lineno">  59</tt>  <tt class="py-line"><tt class="py-docstring"> - getgeodesicpts: computes the points on the surface of the sphere</tt> </tt>
<a name="L60"></a><tt class="py-lineno">  60</tt>  <tt class="py-line"><tt class="py-docstring"> corresponding to a twenty-sided (icosahedral) geodesic.</tt> </tt>
<a name="L61"></a><tt class="py-lineno">  61</tt>  <tt class="py-line"><tt class="py-docstring"> - specintrp: spectral interpolation to an arbitrary point on the sphere.</tt> </tt>
<a name="L62"></a><tt class="py-lineno">  62</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L63"></a><tt class="py-lineno">  63</tt>  <tt class="py-line"><tt class="py-docstring">Conventions</tt> </tt>
<a name="L64"></a><tt class="py-lineno">  64</tt>  <tt class="py-line"><tt class="py-docstring">===========</tt> </tt>
<a name="L65"></a><tt class="py-lineno">  65</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L66"></a><tt class="py-lineno">  66</tt>  <tt class="py-line"><tt class="py-docstring">The gridded data is assumed to be oriented such that i=1 is the</tt> </tt>
<a name="L67"></a><tt class="py-lineno">  67</tt>  <tt class="py-line"><tt class="py-docstring">Greenwich meridian and j=1 is the northernmost point. Grid indices</tt> </tt>
<a name="L68"></a><tt class="py-lineno">  68</tt>  <tt class="py-line"><tt class="py-docstring">increase eastward and southward. If nlat is odd the equator is included.</tt> </tt>
<a name="L69"></a><tt class="py-lineno">  69</tt>  <tt class="py-line"><tt class="py-docstring">If nlat is even the equator will lie half way between points nlat/2</tt> </tt>
<a name="L70"></a><tt class="py-lineno">  70</tt>  <tt class="py-line"><tt class="py-docstring">and (nlat/2)+1. nlat must be at least 3. For regular grids</tt> </tt>
<a name="L71"></a><tt class="py-lineno">  71</tt>  <tt class="py-line"><tt class="py-docstring">(gridtype='regular') the poles will be included when nlat is odd.</tt> </tt>
<a name="L72"></a><tt class="py-lineno">  72</tt>  <tt class="py-line"><tt class="py-docstring">The grid increment in longitude is 2*pi/nlon radians. For example,</tt> </tt>
<a name="L73"></a><tt class="py-lineno">  73</tt>  <tt class="py-line"><tt class="py-docstring">nlon = 72 for a five degree grid. nlon must be greater than or</tt> </tt>
<a name="L74"></a><tt class="py-lineno">  74</tt>  <tt class="py-line"><tt class="py-docstring">equal to 4. The efficiency of the computation is improved when nlon</tt> </tt>
<a name="L75"></a><tt class="py-lineno">  75</tt>  <tt class="py-line"><tt class="py-docstring">is a product of small prime numbers.</tt> </tt>
<a name="L76"></a><tt class="py-lineno">  76</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L77"></a><tt class="py-lineno">  77</tt>  <tt class="py-line"><tt class="py-docstring">The spectral data is assumed to be in a complex array of dimension</tt> </tt>
<a name="L78"></a><tt class="py-lineno">  78</tt>  <tt class="py-line"><tt class="py-docstring">(ntrunc+1)*(ntrunc+2)/2. ntrunc is the triangular truncation limit</tt> </tt>
<a name="L79"></a><tt class="py-lineno">  79</tt>  <tt class="py-line"><tt class="py-docstring">(ntrunc = 42 for T42). ntrunc must be &lt;= nlat-1. Coefficients are</tt> </tt>
<a name="L80"></a><tt class="py-lineno">  80</tt>  <tt class="py-line"><tt class="py-docstring">ordered so that first (nm=0) is m=0,n=0, second is m=0,n=1,</tt> </tt>
<a name="L81"></a><tt class="py-lineno">  81</tt>  <tt class="py-line"><tt class="py-docstring">nm=ntrunc is m=0,n=ntrunc, nm=ntrunc+1 is m=1,n=1, etc.</tt> </tt>
<a name="L82"></a><tt class="py-lineno">  82</tt>  <tt class="py-line"><tt class="py-docstring">The values of m (degree) and n (order) as a function of the index</tt> </tt>
<a name="L83"></a><tt class="py-lineno">  83</tt>  <tt class="py-line"><tt class="py-docstring">nm are given by the arrays indxm, indxn returned by getspecindx.</tt> </tt>
<a name="L84"></a><tt class="py-lineno">  84</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L85"></a><tt class="py-lineno">  85</tt>  <tt class="py-line"><tt class="py-docstring">The associated legendre polynomials are normalized so that the</tt> </tt>
<a name="L86"></a><tt class="py-lineno">  86</tt>  <tt class="py-line"><tt class="py-docstring">integral (pbar(n,m,theta)**2)*sin(theta) on the interval theta=0 to pi</tt> </tt>
<a name="L87"></a><tt class="py-lineno">  87</tt>  <tt class="py-line"><tt class="py-docstring">is 1, where pbar(m,n,theta)=sqrt((2*n+1)*factorial(n-m)/(2*factorial(n+m)))*</tt> </tt>
<a name="L88"></a><tt class="py-lineno">  88</tt>  <tt class="py-line"><tt class="py-docstring">sin(theta)**m/(2**n*factorial(n)) times the (n+m)th derivative of</tt> </tt>
<a name="L89"></a><tt class="py-lineno">  89</tt>  <tt class="py-line"><tt class="py-docstring">(x**2-1)**n with respect to x=cos(theta).</tt> </tt>
<a name="L90"></a><tt class="py-lineno">  90</tt>  <tt class="py-line"><tt class="py-docstring">theta = pi/2 - phi, where phi is latitude and theta is colatitude.</tt> </tt>
<a name="L91"></a><tt class="py-lineno">  91</tt>  <tt class="py-line"><tt class="py-docstring">Therefore, cos(theta) = sin(phi) and sin(theta) = cos(phi).</tt> </tt>
<a name="L92"></a><tt class="py-lineno">  92</tt>  <tt class="py-line"><tt class="py-docstring">Note that pbar(0,0,theta)=sqrt(2)/2, and pbar(1,0,theta)=.5*sqrt(6)*sin(lat).</tt> </tt>
<a name="L93"></a><tt class="py-lineno">  93</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L94"></a><tt class="py-lineno">  94</tt>  <tt class="py-line"><tt class="py-docstring">The default grid type is regular (equally spaced latitude points).</tt> </tt>
<a name="L95"></a><tt class="py-lineno">  95</tt>  <tt class="py-line"><tt class="py-docstring">Set gridtype='gaussian' when creating a class instance</tt> </tt>
<a name="L96"></a><tt class="py-lineno">  96</tt>  <tt class="py-line"><tt class="py-docstring">for gaussian latitude points.</tt> </tt>
<a name="L97"></a><tt class="py-lineno">  97</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L98"></a><tt class="py-lineno">  98</tt>  <tt class="py-line"><tt class="py-docstring">Quantities needed to compute spherical harmonics are precomputed and stored</tt> </tt>
<a name="L99"></a><tt class="py-lineno">  99</tt>  <tt class="py-line"><tt class="py-docstring">when the class instance is created with legfunc='stored' (the default).</tt> </tt>
<a name="L100"></a><tt class="py-lineno"> 100</tt>  <tt class="py-line"><tt class="py-docstring">If legfunc='computed', they are recomputed on the fly on each method call.</tt> </tt>
<a name="L101"></a><tt class="py-lineno"> 101</tt>  <tt class="py-line"><tt class="py-docstring">The storage requirements for legfunc="stored" increase like nlat**2, while</tt> </tt>
<a name="L102"></a><tt class="py-lineno"> 102</tt>  <tt class="py-line"><tt class="py-docstring">those for legfunc='stored' increase like nlat**3.  However, for</tt> </tt>
<a name="L103"></a><tt class="py-lineno"> 103</tt>  <tt class="py-line"><tt class="py-docstring">repeated method invocations on a single class instance, legfunc="stored"</tt> </tt>
<a name="L104"></a><tt class="py-lineno"> 104</tt>  <tt class="py-line"><tt class="py-docstring">will always be faster.</tt> </tt>
<a name="L105"></a><tt class="py-lineno"> 105</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L106"></a><tt class="py-lineno"> 106</tt>  <tt class="py-line"><tt class="py-docstring">@contact: U{Jeff Whitaker&lt;mailto:jeffrey.s.whitaker@noaa.gov&gt;}</tt> </tt>
<a name="L107"></a><tt class="py-lineno"> 107</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L108"></a><tt class="py-lineno"> 108</tt>  <tt class="py-line"><tt class="py-docstring">@version: 1.0.7</tt> </tt>
<a name="L109"></a><tt class="py-lineno"> 109</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L110"></a><tt class="py-lineno"> 110</tt>  <tt class="py-line"><tt class="py-docstring">@license: Permission to use, copy, modify, and distribute this software and its</tt> </tt>
<a name="L111"></a><tt class="py-lineno"> 111</tt>  <tt class="py-line"><tt class="py-docstring">documentation for any purpose and without fee is hereby granted,</tt> </tt>
<a name="L112"></a><tt class="py-lineno"> 112</tt>  <tt class="py-line"><tt class="py-docstring">provided that the above copyright notice appear in all copies and that</tt> </tt>
<a name="L113"></a><tt class="py-lineno"> 113</tt>  <tt class="py-line"><tt class="py-docstring">both that copyright notice and this permission notice appear in</tt> </tt>
<a name="L114"></a><tt class="py-lineno"> 114</tt>  <tt class="py-line"><tt class="py-docstring">supporting documentation.</tt> </tt>
<a name="L115"></a><tt class="py-lineno"> 115</tt>  <tt class="py-line"><tt class="py-docstring">THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,</tt> </tt>
<a name="L116"></a><tt class="py-lineno"> 116</tt>  <tt class="py-line"><tt class="py-docstring">INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO</tt> </tt>
<a name="L117"></a><tt class="py-lineno"> 117</tt>  <tt class="py-line"><tt class="py-docstring">EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR</tt> </tt>
<a name="L118"></a><tt class="py-lineno"> 118</tt>  <tt class="py-line"><tt class="py-docstring">CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF</tt> </tt>
<a name="L119"></a><tt class="py-lineno"> 119</tt>  <tt class="py-line"><tt class="py-docstring">USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR</tt> </tt>
<a name="L120"></a><tt class="py-lineno"> 120</tt>  <tt class="py-line"><tt class="py-docstring">OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR</tt> </tt>
<a name="L121"></a><tt class="py-lineno"> 121</tt>  <tt class="py-line"><tt class="py-docstring">PERFORMANCE OF THIS SOFTWARE.</tt> </tt>
<a name="L122"></a><tt class="py-lineno"> 122</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L123"></a><tt class="py-lineno"> 123</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">,</tt> <tt class="py-name">numpy</tt><tt class="py-op">,</tt> <tt class="py-name">math</tt><tt class="py-op">,</tt> <tt class="py-name">sys</tt> </tt>
<a name="L124"></a><tt class="py-lineno"> 124</tt>  <tt class="py-line"> </tt>
<a name="L125"></a><tt class="py-lineno"> 125</tt>  <tt class="py-line"><tt class="py-comment"># define a list of instance variables that cannot be rebound</tt> </tt>
<a name="L126"></a><tt class="py-lineno"> 126</tt>  <tt class="py-line"><tt class="py-comment"># or unbound.</tt> </tt>
<a name="L127"></a><tt class="py-lineno"> 127</tt>  <tt class="py-line"><tt id="link-0" class="py-name" targets="Variable spharm.spharm._private_vars=spharm.spharm-module.html#_private_vars"><a title="spharm.spharm._private_vars" class="py-name" href="#" onclick="return doclink('link-0', '_private_vars', 'link-0');">_private_vars</a></tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-string">'nlon'</tt><tt class="py-op">,</tt><tt class="py-string">'nlat'</tt><tt class="py-op">,</tt><tt class="py-string">'gridtype'</tt><tt class="py-op">,</tt><tt class="py-string">'legfunc'</tt><tt class="py-op">,</tt><tt class="py-string">'rsphere'</tt><tt class="py-op">]</tt> </tt>
<a name="L128"></a><tt class="py-lineno"> 128</tt>  <tt class="py-line"><tt id="link-1" class="py-name" targets="Variable spharm.spharm.__version__=spharm.spharm-module.html#__version__"><a title="spharm.spharm.__version__" class="py-name" href="#" onclick="return doclink('link-1', '__version__', 'link-1');">__version__</a></tt> <tt class="py-op">=</tt> <tt class="py-string">'1.0.9'</tt> </tt>
<a name="L129"></a><tt class="py-lineno"> 129</tt>  <tt class="py-line"> </tt>
<a name="Spharmt"></a><div id="Spharmt-def"><a name="L130"></a><tt class="py-lineno"> 130</tt> <a class="py-toggle" href="#" id="Spharmt-toggle" onclick="return toggle('Spharmt');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="spharm.spharm.Spharmt-class.html">Spharmt</a><tt class="py-op">:</tt> </tt>
</div><div id="Spharmt-collapsed" style="display:none;" pad="++++" indent="++++"></div><div id="Spharmt-expanded"><a name="L131"></a><tt class="py-lineno"> 131</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L132"></a><tt class="py-lineno"> 132</tt>  <tt class="py-line"><tt class="py-docstring"> spherical harmonic transform class.</tt> </tt>
<a name="L133"></a><tt class="py-lineno"> 133</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L134"></a><tt class="py-lineno"> 134</tt>  <tt class="py-line"><tt class="py-docstring"> @ivar nlat: number of latitudes (set when class instance is created,</tt> </tt>
<a name="L135"></a><tt class="py-lineno"> 135</tt>  <tt class="py-line"><tt class="py-docstring"> cannot be changed).</tt> </tt>
<a name="L136"></a><tt class="py-lineno"> 136</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L137"></a><tt class="py-lineno"> 137</tt>  <tt class="py-line"><tt class="py-docstring"> @ivar nlon: number of longitudes (set when class instance is created,</tt> </tt>
<a name="L138"></a><tt class="py-lineno"> 138</tt>  <tt class="py-line"><tt class="py-docstring"> cannot be changed).</tt> </tt>
<a name="L139"></a><tt class="py-lineno"> 139</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L140"></a><tt class="py-lineno"> 140</tt>  <tt class="py-line"><tt class="py-docstring"> @ivar rsphere: The radius of the sphere in meters (set when class</tt> </tt>
<a name="L141"></a><tt class="py-lineno"> 141</tt>  <tt class="py-line"><tt class="py-docstring"> instance is created, cannot be changed).</tt> </tt>
<a name="L142"></a><tt class="py-lineno"> 142</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L143"></a><tt class="py-lineno"> 143</tt>  <tt class="py-line"><tt class="py-docstring"> @ivar legfunc: 'stored' or 'computed'.  If 'stored',</tt> </tt>
<a name="L144"></a><tt class="py-lineno"> 144</tt>  <tt class="py-line"><tt class="py-docstring"> associated legendre functions are precomputed and stored when the</tt> </tt>
<a name="L145"></a><tt class="py-lineno"> 145</tt>  <tt class="py-line"><tt class="py-docstring"> class instance is created.  If 'computed', associated</tt> </tt>
<a name="L146"></a><tt class="py-lineno"> 146</tt>  <tt class="py-line"><tt class="py-docstring"> legendre functions are computed on the fly when transforms are</tt> </tt>
<a name="L147"></a><tt class="py-lineno"> 147</tt>  <tt class="py-line"><tt class="py-docstring"> requested. Set when class instance is created, cannot be changed.</tt> </tt>
<a name="L148"></a><tt class="py-lineno"> 148</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L149"></a><tt class="py-lineno"> 149</tt>  <tt class="py-line"><tt class="py-docstring"> @ivar gridtype: 'regular' (equally spaced in longitude and latitude)</tt> </tt>
<a name="L150"></a><tt class="py-lineno"> 150</tt>  <tt class="py-line"><tt class="py-docstring"> or 'gaussian' (equally spaced in longitude, latitudes located at</tt> </tt>
<a name="L151"></a><tt class="py-lineno"> 151</tt>  <tt class="py-line"><tt class="py-docstring"> roots of ordinary Legendre polynomial of degree nlat). Set when class</tt> </tt>
<a name="L152"></a><tt class="py-lineno"> 152</tt>  <tt class="py-line"><tt class="py-docstring"> instance is created, cannot be changed.</tt> </tt>
<a name="L153"></a><tt class="py-lineno"> 153</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L154"></a><tt class="py-lineno"> 154</tt>  <tt class="py-line"> </tt>
<a name="Spharmt.__setattr__"></a><div id="Spharmt.__setattr__-def"><a name="L155"></a><tt class="py-lineno"> 155</tt> <a class="py-toggle" href="#" id="Spharmt.__setattr__-toggle" onclick="return toggle('Spharmt.__setattr__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="spharm.spharm.Spharmt-class.html#__setattr__">__setattr__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">key</tt><tt class="py-op">,</tt> <tt class="py-param">val</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Spharmt.__setattr__-collapsed" style="display:none;" pad="++++" indent="++++++++"></div><div id="Spharmt.__setattr__-expanded"><a name="L156"></a><tt class="py-lineno"> 156</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L157"></a><tt class="py-lineno"> 157</tt>  <tt class="py-line"><tt class="py-docstring">prevent modification of read-only instance variables.</tt> </tt>
<a name="L158"></a><tt class="py-lineno"> 158</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L159"></a><tt class="py-lineno"> 159</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">key</tt> <tt class="py-keyword">in</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">__dict__</tt> <tt class="py-keyword">and</tt> <tt class="py-name">key</tt> <tt class="py-keyword">in</tt> <tt id="link-2" class="py-name"><a title="spharm.spharm._private_vars" class="py-name" href="#" onclick="return doclink('link-2', '_private_vars', 'link-0');">_private_vars</a></tt><tt class="py-op">:</tt> </tt>
<a name="L160"></a><tt class="py-lineno"> 160</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">AttributeError</tt><tt class="py-op">(</tt><tt class="py-string">'Attempt to rebind read-only instance variable '</tt><tt class="py-op">+</tt><tt class="py-name">key</tt><tt class="py-op">)</tt> </tt>
<a name="L161"></a><tt class="py-lineno"> 161</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L162"></a><tt class="py-lineno"> 162</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">__dict__</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">val</tt> </tt>
</div><a name="L163"></a><tt class="py-lineno"> 163</tt>  <tt class="py-line"> </tt>
<a name="Spharmt.__delattr__"></a><div id="Spharmt.__delattr__-def"><a name="L164"></a><tt class="py-lineno"> 164</tt> <a class="py-toggle" href="#" id="Spharmt.__delattr__-toggle" onclick="return toggle('Spharmt.__delattr__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="spharm.spharm.Spharmt-class.html#__delattr__">__delattr__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">key</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Spharmt.__delattr__-collapsed" style="display:none;" pad="++++" indent="++++++++"></div><div id="Spharmt.__delattr__-expanded"><a name="L165"></a><tt class="py-lineno"> 165</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L166"></a><tt class="py-lineno"> 166</tt>  <tt class="py-line"><tt class="py-docstring">prevent deletion of read-only instance variables.</tt> </tt>
<a name="L167"></a><tt class="py-lineno"> 167</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L168"></a><tt class="py-lineno"> 168</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">key</tt> <tt class="py-keyword">in</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">__dict__</tt> <tt class="py-keyword">and</tt> <tt class="py-name">key</tt> <tt class="py-keyword">in</tt> <tt id="link-3" class="py-name"><a title="spharm.spharm._private_vars" class="py-name" href="#" onclick="return doclink('link-3', '_private_vars', 'link-0');">_private_vars</a></tt><tt class="py-op">:</tt> </tt>
<a name="L169"></a><tt class="py-lineno"> 169</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">AttributeError</tt><tt class="py-op">(</tt><tt class="py-string">'Attempt to unbind read-only instance variable '</tt><tt class="py-op">+</tt><tt class="py-name">key</tt><tt class="py-op">)</tt> </tt>
<a name="L170"></a><tt class="py-lineno"> 170</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L171"></a><tt class="py-lineno"> 171</tt>  <tt class="py-line">            <tt class="py-keyword">del</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">__dict__</tt><tt class="py-op">[</tt><tt class="py-name">key</tt><tt class="py-op">]</tt> </tt>
</div><a name="L172"></a><tt class="py-lineno"> 172</tt>  <tt class="py-line"> </tt>
<a name="Spharmt.__init__"></a><div id="Spharmt.__init__-def"><a name="L173"></a><tt class="py-lineno"> 173</tt> <a class="py-toggle" href="#" id="Spharmt.__init__-toggle" onclick="return toggle('Spharmt.__init__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="spharm.spharm.Spharmt-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">nlon</tt><tt class="py-op">,</tt> <tt class="py-param">nlat</tt><tt class="py-op">,</tt> <tt class="py-param">rsphere</tt><tt class="py-op">=</tt><tt class="py-number">6.3712e6</tt><tt class="py-op">,</tt> <tt class="py-param">gridtype</tt><tt class="py-op">=</tt><tt class="py-string">'regular'</tt><tt class="py-op">,</tt> <tt class="py-param">legfunc</tt><tt class="py-op">=</tt><tt class="py-string">'stored'</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Spharmt.__init__-collapsed" style="display:none;" pad="++++" indent="++++++++"></div><div id="Spharmt.__init__-expanded"><a name="L174"></a><tt class="py-lineno"> 174</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L175"></a><tt class="py-lineno"> 175</tt>  <tt class="py-line"><tt class="py-docstring"> create a Spharmt class instance.</tt> </tt>
<a name="L176"></a><tt class="py-lineno"> 176</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L177"></a><tt class="py-lineno"> 177</tt>  <tt class="py-line"><tt class="py-docstring"> @param nlon: Number of longitudes. The grid must be oriented from</tt> </tt>
<a name="L178"></a><tt class="py-lineno"> 178</tt>  <tt class="py-line"><tt class="py-docstring"> east to west, with the first point at the Greenwich meridian</tt> </tt>
<a name="L179"></a><tt class="py-lineno"> 179</tt>  <tt class="py-line"><tt class="py-docstring"> and the last point at 360-delta degrees east</tt> </tt>
<a name="L180"></a><tt class="py-lineno"> 180</tt>  <tt class="py-line"><tt class="py-docstring"> (where delta = 360/nlon degrees). Must be &gt;= 4. Transforms will</tt> </tt>
<a name="L181"></a><tt class="py-lineno"> 181</tt>  <tt class="py-line"><tt class="py-docstring"> be faster when nlon is the product of small primes.</tt> </tt>
<a name="L182"></a><tt class="py-lineno"> 182</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L183"></a><tt class="py-lineno"> 183</tt>  <tt class="py-line"><tt class="py-docstring"> @param nlat: Number of latitudes.  The grid must be oriented from north</tt> </tt>
<a name="L184"></a><tt class="py-lineno"> 184</tt>  <tt class="py-line"><tt class="py-docstring"> to south. If nlat is odd the equator is included.</tt> </tt>
<a name="L185"></a><tt class="py-lineno"> 185</tt>  <tt class="py-line"><tt class="py-docstring"> If nlat is even the equator will lie half way between points</tt> </tt>
<a name="L186"></a><tt class="py-lineno"> 186</tt>  <tt class="py-line"><tt class="py-docstring"> points nlat/2 and (nlat/2)+1. Must be &gt;=3.</tt> </tt>
<a name="L187"></a><tt class="py-lineno"> 187</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L188"></a><tt class="py-lineno"> 188</tt>  <tt class="py-line"><tt class="py-docstring"> @keyword rsphere: The radius of the sphere in meters.</tt> </tt>
<a name="L189"></a><tt class="py-lineno"> 189</tt>  <tt class="py-line"><tt class="py-docstring"> Default 6371200 (the value for Earth).</tt> </tt>
<a name="L190"></a><tt class="py-lineno"> 190</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L191"></a><tt class="py-lineno"> 191</tt>  <tt class="py-line"><tt class="py-docstring"> @keyword legfunc: 'stored' (default) or 'computed'.  If 'stored',</tt> </tt>
<a name="L192"></a><tt class="py-lineno"> 192</tt>  <tt class="py-line"><tt class="py-docstring"> associated legendre functions are precomputed and stored when the</tt> </tt>
<a name="L193"></a><tt class="py-lineno"> 193</tt>  <tt class="py-line"><tt class="py-docstring"> class instance is created.  This uses O(nlat**3) memory, but</tt> </tt>
<a name="L194"></a><tt class="py-lineno"> 194</tt>  <tt class="py-line"><tt class="py-docstring"> speeds up the spectral transforms.  If 'computed', associated</tt> </tt>
<a name="L195"></a><tt class="py-lineno"> 195</tt>  <tt class="py-line"><tt class="py-docstring"> legendre functions are computed on the fly when transforms are</tt> </tt>
<a name="L196"></a><tt class="py-lineno"> 196</tt>  <tt class="py-line"><tt class="py-docstring"> requested.  This uses O(nlat**2) memory, but slows down the spectral</tt> </tt>
<a name="L197"></a><tt class="py-lineno"> 197</tt>  <tt class="py-line"><tt class="py-docstring"> transforms a bit.</tt> </tt>
<a name="L198"></a><tt class="py-lineno"> 198</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L199"></a><tt class="py-lineno"> 199</tt>  <tt class="py-line"><tt class="py-docstring"> @keyword gridtype: 'regular' (default) or 'gaussian'. Regular grids</tt> </tt>
<a name="L200"></a><tt class="py-lineno"> 200</tt>  <tt class="py-line"><tt class="py-docstring"> will include the poles and equator if nlat is odd.  Gaussian</tt> </tt>
<a name="L201"></a><tt class="py-lineno"> 201</tt>  <tt class="py-line"><tt class="py-docstring"> grids never include the poles, but will include the equator if</tt> </tt>
<a name="L202"></a><tt class="py-lineno"> 202</tt>  <tt class="py-line"><tt class="py-docstring"> nlat is odd.</tt> </tt>
<a name="L203"></a><tt class="py-lineno"> 203</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L204"></a><tt class="py-lineno"> 204</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L205"></a><tt class="py-lineno"> 205</tt>  <tt class="py-line"><tt class="py-comment"># sanity checks.</tt> </tt>
<a name="L206"></a><tt class="py-lineno"> 206</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">rsphere</tt> <tt class="py-op">&gt;</tt> <tt class="py-number">0.0</tt><tt class="py-op">:</tt> </tt>
<a name="L207"></a><tt class="py-lineno"> 207</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">rsphere</tt><tt class="py-op">=</tt> <tt class="py-name">rsphere</tt> </tt>
<a name="L208"></a><tt class="py-lineno"> 208</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L209"></a><tt class="py-lineno"> 209</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'Spharmt.__init__ illegal value of rsphere (%s) - must be postitive'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">rsphere</tt><tt class="py-op">)</tt> </tt>
<a name="L210"></a><tt class="py-lineno"> 210</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L211"></a><tt class="py-lineno"> 211</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">nlon</tt> <tt class="py-op">&gt;</tt> <tt class="py-number">3</tt><tt class="py-op">:</tt> </tt>
<a name="L212"></a><tt class="py-lineno"> 212</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlon</tt> <tt class="py-op">=</tt> <tt class="py-name">nlon</tt> </tt>
<a name="L213"></a><tt class="py-lineno"> 213</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L214"></a><tt class="py-lineno"> 214</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'Spharmt.__init__ illegal value of nlon (%s) - must be at least 4'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt><tt class="py-op">)</tt> </tt>
<a name="L215"></a><tt class="py-lineno"> 215</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L216"></a><tt class="py-lineno"> 216</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">nlat</tt> <tt class="py-op">&gt;</tt> <tt class="py-number">2</tt><tt class="py-op">:</tt> </tt>
<a name="L217"></a><tt class="py-lineno"> 217</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt> </tt>
<a name="L218"></a><tt class="py-lineno"> 218</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L219"></a><tt class="py-lineno"> 219</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'Spharmt.__init__ illegal value of nlat (%s) - must be at least 3'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt><tt class="py-op">)</tt> </tt>
<a name="L220"></a><tt class="py-lineno"> 220</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L221"></a><tt class="py-lineno"> 221</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">gridtype</tt> <tt class="py-op">!=</tt> <tt class="py-string">'regular'</tt> <tt class="py-keyword">and</tt> <tt class="py-name">gridtype</tt> <tt class="py-op">!=</tt> <tt class="py-string">'gaussian'</tt><tt class="py-op">:</tt> </tt>
<a name="L222"></a><tt class="py-lineno"> 222</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'Spharmt.__init__ illegal value of gridtype (%s) - must be either "gaussian" or "regular"'</tt> <tt class="py-op">%</tt> <tt class="py-name">gridtype</tt> </tt>
<a name="L223"></a><tt class="py-lineno"> 223</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L224"></a><tt class="py-lineno"> 224</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L225"></a><tt class="py-lineno"> 225</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">gridtype</tt> <tt class="py-op">=</tt> <tt class="py-name">gridtype</tt> </tt>
<a name="L226"></a><tt class="py-lineno"> 226</tt>  <tt class="py-line"> </tt>
<a name="L227"></a><tt class="py-lineno"> 227</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">legfunc</tt> <tt class="py-op">!=</tt> <tt class="py-string">'computed'</tt> <tt class="py-keyword">and</tt> <tt class="py-name">legfunc</tt> <tt class="py-op">!=</tt> <tt class="py-string">'stored'</tt><tt class="py-op">:</tt> </tt>
<a name="L228"></a><tt class="py-lineno"> 228</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'Spharmt.__init__ illegal value of legfunc (%s) - must be either "computed" or "stored"'</tt> <tt class="py-op">%</tt> <tt class="py-name">legfunc</tt> </tt>
<a name="L229"></a><tt class="py-lineno"> 229</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L230"></a><tt class="py-lineno"> 230</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L231"></a><tt class="py-lineno"> 231</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">legfunc</tt> <tt class="py-op">=</tt> <tt class="py-name">legfunc</tt> </tt>
<a name="L232"></a><tt class="py-lineno"> 232</tt>  <tt class="py-line"> </tt>
<a name="L233"></a><tt class="py-lineno"> 233</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">nlon</tt><tt class="py-op">%</tt><tt class="py-number">2</tt><tt class="py-op">:</tt>                              <tt class="py-comment"># nlon is odd</tt> </tt>
<a name="L234"></a><tt class="py-lineno"> 234</tt>  <tt class="py-line">            <tt class="py-name">n1</tt> <tt class="py-op">=</tt> <tt class="py-name">min</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">nlon</tt> <tt class="py-op">+</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt><tt class="py-op">)</tt> </tt>
<a name="L235"></a><tt class="py-lineno"> 235</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L236"></a><tt class="py-lineno"> 236</tt>  <tt class="py-line">            <tt class="py-name">n1</tt> <tt class="py-op">=</tt> <tt class="py-name">min</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">nlon</tt> <tt class="py-op">+</tt> <tt class="py-number">2</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt><tt class="py-op">)</tt> </tt>
<a name="L237"></a><tt class="py-lineno"> 237</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">nlat</tt><tt class="py-op">%</tt><tt class="py-number">2</tt><tt class="py-op">:</tt>                              <tt class="py-comment"># nlat is odd</tt> </tt>
<a name="L238"></a><tt class="py-lineno"> 238</tt>  <tt class="py-line">            <tt class="py-name">n2</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> </tt>
<a name="L239"></a><tt class="py-lineno"> 239</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L240"></a><tt class="py-lineno"> 240</tt>  <tt class="py-line">            <tt class="py-name">n2</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> </tt>
<a name="L241"></a><tt class="py-lineno"> 241</tt>  <tt class="py-line"> </tt>
<a name="L242"></a><tt class="py-lineno"> 242</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">gridtype</tt> <tt class="py-op">==</tt> <tt class="py-string">'regular'</tt><tt class="py-op">:</tt> </tt>
<a name="L243"></a><tt class="py-lineno"> 243</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">legfunc</tt> <tt class="py-op">==</tt> <tt class="py-string">'stored'</tt><tt class="py-op">:</tt> </tt>
<a name="L244"></a><tt class="py-lineno"> 244</tt>  <tt class="py-line">                <tt class="py-name">lshaes</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">n1</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-name">nlat</tt> <tt class="py-op">-</tt> <tt class="py-name">n1</tt> <tt class="py-op">+</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> <tt class="py-op">+</tt> <tt class="py-name">nlon</tt> <tt class="py-op">+</tt> <tt class="py-number">15</tt> </tt>
<a name="L245"></a><tt class="py-lineno"> 245</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-number">5</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt> <tt class="py-op">+</tt> <tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-op">(</tt><tt class="py-name">n1</tt> <tt class="py-op">-</tt> <tt class="py-number">2</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-name">nlat</tt> <tt class="py-op">-</tt> <tt class="py-name">n1</tt> <tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> </tt>
<a name="L246"></a><tt class="py-lineno"> 246</tt>  <tt class="py-line">                <tt class="py-name">wshaes</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">shaesi</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">lshaes</tt><tt class="py-op">,</tt> <tt class="py-name">lwork</tt><tt class="py-op">,</tt> <tt class="py-name">nlat</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt> </tt>
<a name="L247"></a><tt class="py-lineno"> 247</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L248"></a><tt class="py-lineno"> 248</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to shaesi in Spharmt.__init__ ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L249"></a><tt class="py-lineno"> 249</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L250"></a><tt class="py-lineno"> 250</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wshaes</tt> <tt class="py-op">=</tt> <tt class="py-name">wshaes</tt> </tt>
<a name="L251"></a><tt class="py-lineno"> 251</tt>  <tt class="py-line">                <tt class="py-name">lshses</tt> <tt class="py-op">=</tt> <tt class="py-name">lshaes</tt> </tt>
<a name="L252"></a><tt class="py-lineno"> 252</tt>  <tt class="py-line">                <tt class="py-name">wshses</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">shsesi</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">lshses</tt><tt class="py-op">,</tt> <tt class="py-name">lwork</tt><tt class="py-op">,</tt> <tt class="py-name">nlat</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt> </tt>
<a name="L253"></a><tt class="py-lineno"> 253</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L254"></a><tt class="py-lineno"> 254</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to shsesi in Spharmt.__init__ ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L255"></a><tt class="py-lineno"> 255</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L256"></a><tt class="py-lineno"> 256</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wshses</tt> <tt class="py-op">=</tt> <tt class="py-name">wshses</tt> </tt>
<a name="L257"></a><tt class="py-lineno"> 257</tt>  <tt class="py-line">                <tt class="py-name">lvhaes</tt> <tt class="py-op">=</tt> <tt class="py-name">n1</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-name">nlat</tt> <tt class="py-op">-</tt> <tt class="py-name">n1</tt> <tt class="py-op">+</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-name">nlon</tt> <tt class="py-op">+</tt> <tt class="py-number">15</tt> </tt>
<a name="L258"></a><tt class="py-lineno"> 258</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">max</tt><tt class="py-op">(</tt><tt class="py-name">n1</tt> <tt class="py-op">-</tt><tt class="py-number">2</tt><tt class="py-op">,</tt><tt class="py-number">0</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-name">nlat</tt> <tt class="py-op">-</tt> <tt class="py-name">n1</tt> <tt class="py-op">-</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> <tt class="py-op">+</tt> <tt class="py-number">5</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt> </tt>
<a name="L259"></a><tt class="py-lineno"> 259</tt>  <tt class="py-line">                <tt class="py-name">wvhaes</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">vhaesi</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">lvhaes</tt><tt class="py-op">,</tt> <tt class="py-name">lwork</tt><tt class="py-op">,</tt> <tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L260"></a><tt class="py-lineno"> 260</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L261"></a><tt class="py-lineno"> 261</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to vhaesi in Spharmt.__init__ ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L262"></a><tt class="py-lineno"> 262</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L263"></a><tt class="py-lineno"> 263</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wvhaes</tt> <tt class="py-op">=</tt> <tt class="py-name">wvhaes</tt> </tt>
<a name="L264"></a><tt class="py-lineno"> 264</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">max</tt><tt class="py-op">(</tt><tt class="py-name">n1</tt> <tt class="py-op">-</tt> <tt class="py-number">2</tt><tt class="py-op">,</tt><tt class="py-number">0</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-name">nlat</tt> <tt class="py-op">-</tt> <tt class="py-name">n1</tt> <tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> <tt class="py-op">+</tt> <tt class="py-number">5</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt> </tt>
<a name="L265"></a><tt class="py-lineno"> 265</tt>  <tt class="py-line">                <tt class="py-name">lvhses</tt> <tt class="py-op">=</tt> <tt class="py-name">n1</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-name">nlat</tt> <tt class="py-op">-</tt> <tt class="py-name">n1</tt> <tt class="py-op">+</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-name">nlon</tt> <tt class="py-op">+</tt> <tt class="py-number">15</tt> </tt>
<a name="L266"></a><tt class="py-lineno"> 266</tt>  <tt class="py-line">                <tt class="py-name">wvhses</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">vhsesi</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt><tt class="py-name">lvhses</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">,</tt><tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L267"></a><tt class="py-lineno"> 267</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L268"></a><tt class="py-lineno"> 268</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to vhsesi in Spharmt.__init__ ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L269"></a><tt class="py-lineno"> 269</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L270"></a><tt class="py-lineno"> 270</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wvhses</tt> <tt class="py-op">=</tt> <tt class="py-name">wvhses</tt> </tt>
<a name="L271"></a><tt class="py-lineno"> 271</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L272"></a><tt class="py-lineno"> 272</tt>  <tt class="py-line">                <tt class="py-name">lshaec</tt> <tt class="py-op">=</tt> <tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">+</tt><tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-op">(</tt><tt class="py-name">n1</tt><tt class="py-op">-</tt><tt class="py-number">2</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">+</tt><tt class="py-name">nlat</tt><tt class="py-op">-</tt><tt class="py-name">n1</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt><tt class="py-op">+</tt><tt class="py-name">nlon</tt><tt class="py-op">+</tt><tt class="py-number">15</tt> </tt>
<a name="L273"></a><tt class="py-lineno"> 273</tt>  <tt class="py-line">                <tt class="py-name">wshaec</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">shaeci</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">lshaec</tt><tt class="py-op">,</tt> <tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L274"></a><tt class="py-lineno"> 274</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L275"></a><tt class="py-lineno"> 275</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to shaeci in Spharmt.__init__ ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L276"></a><tt class="py-lineno"> 276</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L277"></a><tt class="py-lineno"> 277</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wshaec</tt> <tt class="py-op">=</tt> <tt class="py-name">wshaec</tt> </tt>
<a name="L278"></a><tt class="py-lineno"> 278</tt>  <tt class="py-line">                <tt class="py-name">lshsec</tt> <tt class="py-op">=</tt> <tt class="py-name">lshaec</tt> </tt>
<a name="L279"></a><tt class="py-lineno"> 279</tt>  <tt class="py-line">                <tt class="py-name">wshsec</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">shseci</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">lshsec</tt><tt class="py-op">,</tt> <tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L280"></a><tt class="py-lineno"> 280</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L281"></a><tt class="py-lineno"> 281</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to shseci in Spharmt.__init__ ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L282"></a><tt class="py-lineno"> 282</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L283"></a><tt class="py-lineno"> 283</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wshsec</tt> <tt class="py-op">=</tt> <tt class="py-name">wshsec</tt> </tt>
<a name="L284"></a><tt class="py-lineno"> 284</tt>  <tt class="py-line">                <tt class="py-name">lvhaec</tt> <tt class="py-op">=</tt> <tt class="py-number">4</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">+</tt><tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-name">max</tt><tt class="py-op">(</tt><tt class="py-name">n1</tt><tt class="py-op">-</tt><tt class="py-number">2</tt><tt class="py-op">,</tt><tt class="py-number">0</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">-</tt><tt class="py-name">n1</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">+</tt><tt class="py-name">nlon</tt><tt class="py-op">+</tt><tt class="py-number">15</tt> </tt>
<a name="L285"></a><tt class="py-lineno"> 285</tt>  <tt class="py-line">                <tt class="py-name">wvhaec</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">vhaeci</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">lvhaec</tt><tt class="py-op">,</tt>  <tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L286"></a><tt class="py-lineno"> 286</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L287"></a><tt class="py-lineno"> 287</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to vhaeci in Spharmt.__init__ ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L288"></a><tt class="py-lineno"> 288</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L289"></a><tt class="py-lineno"> 289</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wvhaec</tt> <tt class="py-op">=</tt> <tt class="py-name">wvhaec</tt> </tt>
<a name="L290"></a><tt class="py-lineno"> 290</tt>  <tt class="py-line">                <tt class="py-name">lvhsec</tt> <tt class="py-op">=</tt> <tt class="py-name">lvhaec</tt> </tt>
<a name="L291"></a><tt class="py-lineno"> 291</tt>  <tt class="py-line">                <tt class="py-name">wvhsec</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">vhseci</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">lvhsec</tt><tt class="py-op">,</tt>  <tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L292"></a><tt class="py-lineno"> 292</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L293"></a><tt class="py-lineno"> 293</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to vhseci in Spharmt.__init__ ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L294"></a><tt class="py-lineno"> 294</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L295"></a><tt class="py-lineno"> 295</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wvhsec</tt> <tt class="py-op">=</tt> <tt class="py-name">wvhsec</tt> </tt>
<a name="L296"></a><tt class="py-lineno"> 296</tt>  <tt class="py-line"> </tt>
<a name="L297"></a><tt class="py-lineno"> 297</tt>  <tt class="py-line"> </tt>
<a name="L298"></a><tt class="py-lineno"> 298</tt>  <tt class="py-line">        <tt class="py-keyword">elif</tt> <tt class="py-name">gridtype</tt> <tt class="py-op">==</tt> <tt class="py-string">'gaussian'</tt><tt class="py-op">:</tt> </tt>
<a name="L299"></a><tt class="py-lineno"> 299</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">legfunc</tt> <tt class="py-op">==</tt> <tt class="py-string">'stored'</tt><tt class="py-op">:</tt> </tt>
<a name="L300"></a><tt class="py-lineno"> 300</tt>  <tt class="py-line">                <tt class="py-name">lshags</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">n1</tt> <tt class="py-op">+</tt> <tt class="py-name">n2</tt><tt class="py-op">)</tt> <tt class="py-op">-</tt> <tt class="py-number">2</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-op">(</tt><tt class="py-name">n1</tt> <tt class="py-op">-</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">n2</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt> <tt class="py-op">-</tt> <tt class="py-name">n1</tt><tt class="py-op">)</tt> <tt class="py-op">-</tt> <tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-name">n1</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> <tt class="py-op">+</tt> <tt class="py-name">nlon</tt> <tt class="py-op">+</tt> <tt class="py-number">15</tt> </tt>
<a name="L301"></a><tt class="py-lineno"> 301</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-number">4</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-number">2</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-number">2</tt> </tt>
<a name="L302"></a><tt class="py-lineno"> 302</tt>  <tt class="py-line">                <tt class="py-name">ldwork</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-number">4</tt><tt class="py-op">)</tt> </tt>
<a name="L303"></a><tt class="py-lineno"> 303</tt>  <tt class="py-line">                <tt class="py-name">wshags</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">shagsi</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">lshags</tt><tt class="py-op">,</tt> <tt class="py-name">lwork</tt><tt class="py-op">,</tt> <tt class="py-name">ldwork</tt><tt class="py-op">)</tt> </tt>
<a name="L304"></a><tt class="py-lineno"> 304</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L305"></a><tt class="py-lineno"> 305</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to shagsi in Spharmt.__init__ ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L306"></a><tt class="py-lineno"> 306</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L307"></a><tt class="py-lineno"> 307</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wshags</tt> <tt class="py-op">=</tt> <tt class="py-name">wshags</tt> </tt>
<a name="L308"></a><tt class="py-lineno"> 308</tt>  <tt class="py-line">                <tt class="py-name">lshsgs</tt> <tt class="py-op">=</tt> <tt class="py-name">lshags</tt> </tt>
<a name="L309"></a><tt class="py-lineno"> 309</tt>  <tt class="py-line">                <tt class="py-name">wshsgs</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">shsgsi</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">lshsgs</tt><tt class="py-op">,</tt> <tt class="py-name">lwork</tt><tt class="py-op">,</tt> <tt class="py-name">ldwork</tt><tt class="py-op">)</tt> </tt>
<a name="L310"></a><tt class="py-lineno"> 310</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L311"></a><tt class="py-lineno"> 311</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to shsgsi in Spharmt.__init__ ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L312"></a><tt class="py-lineno"> 312</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L313"></a><tt class="py-lineno"> 313</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wshsgs</tt> <tt class="py-op">=</tt> <tt class="py-name">wshsgs</tt> </tt>
<a name="L314"></a><tt class="py-lineno"> 314</tt>  <tt class="py-line">                <tt class="py-name">lvhags</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> <tt class="py-op">+</tt><tt class="py-name">nlon</tt> <tt class="py-op">+</tt> <tt class="py-number">15</tt> </tt>
<a name="L315"></a><tt class="py-lineno"> 315</tt>  <tt class="py-line">                <tt class="py-name">ldwork</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-number">3</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-number">2</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> </tt>
<a name="L316"></a><tt class="py-lineno"> 316</tt>  <tt class="py-line">                <tt class="py-name">wvhags</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">vhagsi</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">lvhags</tt><tt class="py-op">,</tt> <tt class="py-name">ldwork</tt><tt class="py-op">)</tt> </tt>
<a name="L317"></a><tt class="py-lineno"> 317</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L318"></a><tt class="py-lineno"> 318</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to vhagsi in Spharmt.__init__ ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L319"></a><tt class="py-lineno"> 319</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L320"></a><tt class="py-lineno"> 320</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wvhags</tt> <tt class="py-op">=</tt> <tt class="py-name">wvhags</tt> </tt>
<a name="L321"></a><tt class="py-lineno"> 321</tt>  <tt class="py-line">                <tt class="py-name">lvhsgs</tt> <tt class="py-op">=</tt> <tt class="py-name">n1</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-name">nlat</tt> <tt class="py-op">-</tt> <tt class="py-name">n1</tt> <tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-name">nlon</tt> <tt class="py-op">+</tt> <tt class="py-number">15</tt> <tt class="py-op">+</tt> <tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt> </tt>
<a name="L322"></a><tt class="py-lineno"> 322</tt>  <tt class="py-line">                <tt class="py-name">ldwork</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-number">3</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-number">2</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> </tt>
<a name="L323"></a><tt class="py-lineno"> 323</tt>  <tt class="py-line">                <tt class="py-name">wvhsgs</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">vhsgsi</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">lvhsgs</tt><tt class="py-op">,</tt> <tt class="py-name">ldwork</tt><tt class="py-op">)</tt> </tt>
<a name="L324"></a><tt class="py-lineno"> 324</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L325"></a><tt class="py-lineno"> 325</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to vhsgsi in Spharmt.__init__ ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L326"></a><tt class="py-lineno"> 326</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L327"></a><tt class="py-lineno"> 327</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wvhsgs</tt> <tt class="py-op">=</tt> <tt class="py-name">wvhsgs</tt> </tt>
<a name="L328"></a><tt class="py-lineno"> 328</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L329"></a><tt class="py-lineno"> 329</tt>  <tt class="py-line">                <tt class="py-name">lshagc</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">+</tt><tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-name">n1</tt><tt class="py-op">-</tt><tt class="py-number">2</tt><tt class="py-op">)</tt><tt class="py-op">+</tt><tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-name">n1</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-number">1</tt><tt class="py-op">-</tt><tt class="py-name">n1</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt><tt class="py-op">+</tt><tt class="py-name">nlon</tt><tt class="py-op">+</tt><tt class="py-number">15</tt> </tt>
<a name="L330"></a><tt class="py-lineno"> 330</tt>  <tt class="py-line">                <tt class="py-name">wshagc</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">shagci</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">lshagc</tt><tt class="py-op">,</tt> <tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">+</tt><tt class="py-number">4</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L331"></a><tt class="py-lineno"> 331</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L332"></a><tt class="py-lineno"> 332</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to shagci in Spharmt.__init__ ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L333"></a><tt class="py-lineno"> 333</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L334"></a><tt class="py-lineno"> 334</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wshagc</tt> <tt class="py-op">=</tt> <tt class="py-name">wshagc</tt> </tt>
<a name="L335"></a><tt class="py-lineno"> 335</tt>  <tt class="py-line">                <tt class="py-name">lshsgc</tt> <tt class="py-op">=</tt> <tt class="py-name">lshagc</tt> </tt>
<a name="L336"></a><tt class="py-lineno"> 336</tt>  <tt class="py-line">                <tt class="py-name">wshsgc</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">shsgci</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">lshsgc</tt><tt class="py-op">,</tt> <tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">+</tt><tt class="py-number">4</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L337"></a><tt class="py-lineno"> 337</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L338"></a><tt class="py-lineno"> 338</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to shsgci in Spharmt.__init__ ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L339"></a><tt class="py-lineno"> 339</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L340"></a><tt class="py-lineno"> 340</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wshsgc</tt> <tt class="py-op">=</tt> <tt class="py-name">wshsgc</tt> </tt>
<a name="L341"></a><tt class="py-lineno"> 341</tt>  <tt class="py-line">                <tt class="py-name">lvhagc</tt> <tt class="py-op">=</tt> <tt class="py-number">4</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">+</tt><tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-name">max</tt><tt class="py-op">(</tt><tt class="py-name">n1</tt><tt class="py-op">-</tt><tt class="py-number">2</tt><tt class="py-op">,</tt><tt class="py-number">0</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">-</tt><tt class="py-name">n1</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">+</tt><tt class="py-name">nlon</tt><tt class="py-op">+</tt><tt class="py-name">n2</tt><tt class="py-op">+</tt><tt class="py-number">15</tt> </tt>
<a name="L342"></a><tt class="py-lineno"> 342</tt>  <tt class="py-line">                <tt class="py-name">ldwork</tt> <tt class="py-op">=</tt> <tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">+</tt><tt class="py-number">1</tt> </tt>
<a name="L343"></a><tt class="py-lineno"> 343</tt>  <tt class="py-line">                <tt class="py-name">wvhagc</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">vhagci</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">lvhagc</tt><tt class="py-op">,</tt> <tt class="py-name">ldwork</tt><tt class="py-op">)</tt> </tt>
<a name="L344"></a><tt class="py-lineno"> 344</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L345"></a><tt class="py-lineno"> 345</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to vhagci in Spharmt.__init__ ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L346"></a><tt class="py-lineno"> 346</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L347"></a><tt class="py-lineno"> 347</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wvhagc</tt> <tt class="py-op">=</tt> <tt class="py-name">wvhagc</tt> </tt>
<a name="L348"></a><tt class="py-lineno"> 348</tt>  <tt class="py-line">                <tt class="py-name">lvhsgc</tt> <tt class="py-op">=</tt> <tt class="py-number">4</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">+</tt><tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-name">max</tt><tt class="py-op">(</tt><tt class="py-name">n1</tt><tt class="py-op">-</tt><tt class="py-number">2</tt><tt class="py-op">,</tt><tt class="py-number">0</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">-</tt><tt class="py-name">n1</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">+</tt><tt class="py-name">nlon</tt><tt class="py-op">+</tt><tt class="py-number">15</tt> </tt>
<a name="L349"></a><tt class="py-lineno"> 349</tt>  <tt class="py-line">                <tt class="py-name">wvhsgc</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">vhsgci</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">lvhsgc</tt><tt class="py-op">,</tt> <tt class="py-name">ldwork</tt><tt class="py-op">)</tt> </tt>
<a name="L350"></a><tt class="py-lineno"> 350</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L351"></a><tt class="py-lineno"> 351</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to vhsgci in Spharmt.__init__ ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L352"></a><tt class="py-lineno"> 352</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L353"></a><tt class="py-lineno"> 353</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wvhsgc</tt> <tt class="py-op">=</tt> <tt class="py-name">wvhsgc</tt> </tt>
</div><a name="L354"></a><tt class="py-lineno"> 354</tt>  <tt class="py-line"> </tt>
<a name="Spharmt.grdtospec"></a><div id="Spharmt.grdtospec-def"><a name="L355"></a><tt class="py-lineno"> 355</tt> <a class="py-toggle" href="#" id="Spharmt.grdtospec-toggle" onclick="return toggle('Spharmt.grdtospec');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="spharm.spharm.Spharmt-class.html#grdtospec">grdtospec</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">datagrid</tt><tt class="py-op">,</tt> <tt class="py-param">ntrunc</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Spharmt.grdtospec-collapsed" style="display:none;" pad="++++" indent="++++++++"></div><div id="Spharmt.grdtospec-expanded"><a name="L356"></a><tt class="py-lineno"> 356</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L357"></a><tt class="py-lineno"> 357</tt>  <tt class="py-line"><tt class="py-docstring"> grid to spectral transform (spherical harmonic analysis).</tt> </tt>
<a name="L358"></a><tt class="py-lineno"> 358</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L359"></a><tt class="py-lineno"> 359</tt>  <tt class="py-line"><tt class="py-docstring"> @param datagrid: rank 2 or 3 numpy float32 array with shape (nlat,nlon) or</tt> </tt>
<a name="L360"></a><tt class="py-lineno"> 360</tt>  <tt class="py-line"><tt class="py-docstring"> (nlat,nlon,nt), where nt is the number of grids to be transformed.  If</tt> </tt>
<a name="L361"></a><tt class="py-lineno"> 361</tt>  <tt class="py-line"><tt class="py-docstring"> datagrid is rank 2, nt is assumed to be 1.</tt> </tt>
<a name="L362"></a><tt class="py-lineno"> 362</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L363"></a><tt class="py-lineno"> 363</tt>  <tt class="py-line"><tt class="py-docstring"> @keyword ntrunc:  optional spectral truncation limit.</tt> </tt>
<a name="L364"></a><tt class="py-lineno"> 364</tt>  <tt class="py-line"><tt class="py-docstring"> (default self.nlat-1)</tt> </tt>
<a name="L365"></a><tt class="py-lineno"> 365</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L366"></a><tt class="py-lineno"> 366</tt>  <tt class="py-line"><tt class="py-docstring"> @return: C{B{dataspec}} - rank 1 or 2 numpy complex array with shape</tt> </tt>
<a name="L367"></a><tt class="py-lineno"> 367</tt>  <tt class="py-line"><tt class="py-docstring"> (ntrunc+1)*(ntrunc+2)/2 or ((ntrunc+1)*(ntrunc+2)/2,nt) containing</tt> </tt>
<a name="L368"></a><tt class="py-lineno"> 368</tt>  <tt class="py-line"><tt class="py-docstring"> complex spherical harmonic coefficients resulting from the spherical</tt> </tt>
<a name="L369"></a><tt class="py-lineno"> 369</tt>  <tt class="py-line"><tt class="py-docstring"> harmonic analysis of datagrid.</tt> </tt>
<a name="L370"></a><tt class="py-lineno"> 370</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L371"></a><tt class="py-lineno"> 371</tt>  <tt class="py-line"> </tt>
<a name="L372"></a><tt class="py-lineno"> 372</tt>  <tt class="py-line"><tt class="py-comment"># check that datagrid is rank 2 or 3 with size (self.nlat, self.nlon) or</tt> </tt>
<a name="L373"></a><tt class="py-lineno"> 373</tt>  <tt class="py-line"><tt class="py-comment"># (self.nlat, self.nlon, nt) where nt is number of grids to transform.</tt> </tt>
<a name="L374"></a><tt class="py-lineno"> 374</tt>  <tt class="py-line"> </tt>
<a name="L375"></a><tt class="py-lineno"> 375</tt>  <tt class="py-line">        <tt class="py-name">idim</tt> <tt class="py-op">=</tt> <tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">ndim</tt> </tt>
<a name="L376"></a><tt class="py-lineno"> 376</tt>  <tt class="py-line"> </tt>
<a name="L377"></a><tt class="py-lineno"> 377</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt> <tt class="py-op">&gt;</tt> <tt class="py-number">3</tt><tt class="py-op">:</tt> </tt>
<a name="L378"></a><tt class="py-lineno"> 378</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'grdtospec needs a rank two or three array, got %d'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt><tt class="py-op">,</tt><tt class="py-op">)</tt> </tt>
<a name="L379"></a><tt class="py-lineno"> 379</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L380"></a><tt class="py-lineno"> 380</tt>  <tt class="py-line"> </tt>
<a name="L381"></a><tt class="py-lineno"> 381</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt> <tt class="py-keyword">or</tt> <tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlon</tt><tt class="py-op">:</tt> </tt>
<a name="L382"></a><tt class="py-lineno"> 382</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'grdtospec needs an array of size %d by %d, got %d by %d'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">,</tt><tt class="py-op">)</tt> </tt>
<a name="L383"></a><tt class="py-lineno"> 383</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L384"></a><tt class="py-lineno"> 384</tt>  <tt class="py-line"> </tt>
<a name="L385"></a><tt class="py-lineno"> 385</tt>  <tt class="py-line"><tt class="py-comment"># check ntrunc.</tt> </tt>
<a name="L386"></a><tt class="py-lineno"> 386</tt>  <tt class="py-line"> </tt>
<a name="L387"></a><tt class="py-lineno"> 387</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">ntrunc</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
<a name="L388"></a><tt class="py-lineno"> 388</tt>  <tt class="py-line">            <tt class="py-name">ntrunc</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt><tt class="py-op">-</tt><tt class="py-number">1</tt> </tt>
<a name="L389"></a><tt class="py-lineno"> 389</tt>  <tt class="py-line"> </tt>
<a name="L390"></a><tt class="py-lineno"> 390</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">ntrunc</tt> <tt class="py-op">&lt;</tt> <tt class="py-number">0</tt> <tt class="py-keyword">or</tt> <tt class="py-name">ntrunc</tt><tt class="py-op">+</tt><tt class="py-number">1</tt> <tt class="py-op">&gt;</tt> <tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">:</tt> </tt>
<a name="L391"></a><tt class="py-lineno"> 391</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'ntrunc must be between 0 and %d'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">,</tt><tt class="py-op">)</tt> </tt>
<a name="L392"></a><tt class="py-lineno"> 392</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L393"></a><tt class="py-lineno"> 393</tt>  <tt class="py-line"> </tt>
<a name="L394"></a><tt class="py-lineno"> 394</tt>  <tt class="py-line"> </tt>
<a name="L395"></a><tt class="py-lineno"> 395</tt>  <tt class="py-line">        <tt class="py-name">nlat</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt> </tt>
<a name="L396"></a><tt class="py-lineno"> 396</tt>  <tt class="py-line">        <tt class="py-name">nlon</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlon</tt> </tt>
<a name="L397"></a><tt class="py-lineno"> 397</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">nlat</tt><tt class="py-op">%</tt><tt class="py-number">2</tt><tt class="py-op">:</tt>                              <tt class="py-comment"># nlat is odd</tt> </tt>
<a name="L398"></a><tt class="py-lineno"> 398</tt>  <tt class="py-line">            <tt class="py-name">n2</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> </tt>
<a name="L399"></a><tt class="py-lineno"> 399</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L400"></a><tt class="py-lineno"> 400</tt>  <tt class="py-line">            <tt class="py-name">n2</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> </tt>
<a name="L401"></a><tt class="py-lineno"> 401</tt>  <tt class="py-line"> </tt>
<a name="L402"></a><tt class="py-lineno"> 402</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt> <tt class="py-op">==</tt> <tt class="py-number">2</tt><tt class="py-op">:</tt> </tt>
<a name="L403"></a><tt class="py-lineno"> 403</tt>  <tt class="py-line">            <tt class="py-name">nt</tt> <tt class="py-op">=</tt> <tt class="py-number">1</tt> </tt>
<a name="L404"></a><tt class="py-lineno"> 404</tt>  <tt class="py-line">            <tt class="py-name">datagrid</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">reshape</tt><tt class="py-op">(</tt><tt class="py-name">datagrid</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L405"></a><tt class="py-lineno"> 405</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L406"></a><tt class="py-lineno"> 406</tt>  <tt class="py-line">            <tt class="py-name">nt</tt> <tt class="py-op">=</tt> <tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">]</tt> </tt>
<a name="L407"></a><tt class="py-lineno"> 407</tt>  <tt class="py-line"> </tt>
<a name="L408"></a><tt class="py-lineno"> 408</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">gridtype</tt> <tt class="py-op">==</tt> <tt class="py-string">'regular'</tt><tt class="py-op">:</tt> </tt>
<a name="L409"></a><tt class="py-lineno"> 409</tt>  <tt class="py-line"> </tt>
<a name="L410"></a><tt class="py-lineno"> 410</tt>  <tt class="py-line"><tt class="py-comment"># do grid to spectral transform.</tt> </tt>
<a name="L411"></a><tt class="py-lineno"> 411</tt>  <tt class="py-line"> </tt>
<a name="L412"></a><tt class="py-lineno"> 412</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">legfunc</tt> <tt class="py-op">==</tt> <tt class="py-string">'stored'</tt><tt class="py-op">:</tt> </tt>
<a name="L413"></a><tt class="py-lineno"> 413</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">nt</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-name">nlon</tt> </tt>
<a name="L414"></a><tt class="py-lineno"> 414</tt>  <tt class="py-line">                <tt class="py-name">a</tt><tt class="py-op">,</tt><tt class="py-name">b</tt><tt class="py-op">,</tt><tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">shaes</tt><tt class="py-op">(</tt><tt class="py-name">datagrid</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wshaes</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">)</tt> </tt>
<a name="L415"></a><tt class="py-lineno"> 415</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L416"></a><tt class="py-lineno"> 416</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to shaes in Spharmt.grdtospec ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L417"></a><tt class="py-lineno"> 417</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L418"></a><tt class="py-lineno"> 418</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L419"></a><tt class="py-lineno"> 419</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nt</tt><tt class="py-op">*</tt><tt class="py-name">nlon</tt><tt class="py-op">+</tt><tt class="py-name">max</tt><tt class="py-op">(</tt><tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">,</tt><tt class="py-name">nlon</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L420"></a><tt class="py-lineno"> 420</tt>  <tt class="py-line">                <tt class="py-name">a</tt><tt class="py-op">,</tt><tt class="py-name">b</tt><tt class="py-op">,</tt><tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">shaec</tt><tt class="py-op">(</tt><tt class="py-name">datagrid</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wshaec</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">)</tt> </tt>
<a name="L421"></a><tt class="py-lineno"> 421</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L422"></a><tt class="py-lineno"> 422</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to shaec in Spharmt.grdtospec ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L423"></a><tt class="py-lineno"> 423</tt>  <tt class="py-line"> </tt>
<a name="L424"></a><tt class="py-lineno"> 424</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L425"></a><tt class="py-lineno"> 425</tt>  <tt class="py-line"> </tt>
<a name="L426"></a><tt class="py-lineno"> 426</tt>  <tt class="py-line"><tt class="py-comment"># gaussian grid.</tt> </tt>
<a name="L427"></a><tt class="py-lineno"> 427</tt>  <tt class="py-line"> </tt>
<a name="L428"></a><tt class="py-lineno"> 428</tt>  <tt class="py-line">        <tt class="py-keyword">elif</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">gridtype</tt> <tt class="py-op">==</tt> <tt class="py-string">'gaussian'</tt><tt class="py-op">:</tt> </tt>
<a name="L429"></a><tt class="py-lineno"> 429</tt>  <tt class="py-line"> </tt>
<a name="L430"></a><tt class="py-lineno"> 430</tt>  <tt class="py-line"><tt class="py-comment"># do grid to spectral transform.</tt> </tt>
<a name="L431"></a><tt class="py-lineno"> 431</tt>  <tt class="py-line"> </tt>
<a name="L432"></a><tt class="py-lineno"> 432</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">legfunc</tt> <tt class="py-op">==</tt> <tt class="py-string">'stored'</tt><tt class="py-op">:</tt> </tt>
<a name="L433"></a><tt class="py-lineno"> 433</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-name">nlon</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nt</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt> </tt>
<a name="L434"></a><tt class="py-lineno"> 434</tt>  <tt class="py-line">                <tt class="py-name">a</tt><tt class="py-op">,</tt><tt class="py-name">b</tt><tt class="py-op">,</tt><tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">shags</tt><tt class="py-op">(</tt><tt class="py-name">datagrid</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wshags</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">)</tt> </tt>
<a name="L435"></a><tt class="py-lineno"> 435</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L436"></a><tt class="py-lineno"> 436</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to shags in Spharmt.grdtospec ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L437"></a><tt class="py-lineno"> 437</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L438"></a><tt class="py-lineno"> 438</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L439"></a><tt class="py-lineno"> 439</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlon</tt><tt class="py-op">*</tt><tt class="py-name">nt</tt><tt class="py-op">+</tt><tt class="py-name">max</tt><tt class="py-op">(</tt><tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">,</tt><tt class="py-name">nlon</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L440"></a><tt class="py-lineno"> 440</tt>  <tt class="py-line">                <tt class="py-name">a</tt><tt class="py-op">,</tt><tt class="py-name">b</tt><tt class="py-op">,</tt><tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">shagc</tt><tt class="py-op">(</tt><tt class="py-name">datagrid</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wshagc</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">)</tt> </tt>
<a name="L441"></a><tt class="py-lineno"> 441</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L442"></a><tt class="py-lineno"> 442</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to shagc in Spharmt.grdtospec ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L443"></a><tt class="py-lineno"> 443</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L444"></a><tt class="py-lineno"> 444</tt>  <tt class="py-line"> </tt>
<a name="L445"></a><tt class="py-lineno"> 445</tt>  <tt class="py-line"><tt class="py-comment"># convert 2d real and imag spectral arrays into 1d complex array.</tt> </tt>
<a name="L446"></a><tt class="py-lineno"> 446</tt>  <tt class="py-line"> </tt>
<a name="L447"></a><tt class="py-lineno"> 447</tt>  <tt class="py-line">        <tt class="py-name">dataspec</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">twodtooned</tt><tt class="py-op">(</tt><tt class="py-name">a</tt><tt class="py-op">,</tt><tt class="py-name">b</tt><tt class="py-op">,</tt><tt class="py-name">ntrunc</tt><tt class="py-op">)</tt> </tt>
<a name="L448"></a><tt class="py-lineno"> 448</tt>  <tt class="py-line"> </tt>
<a name="L449"></a><tt class="py-lineno"> 449</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">idim</tt> <tt class="py-op">==</tt> <tt class="py-number">2</tt><tt class="py-op">:</tt> </tt>
<a name="L450"></a><tt class="py-lineno"> 450</tt>  <tt class="py-line">            <tt class="py-keyword">return</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">squeeze</tt><tt class="py-op">(</tt><tt class="py-name">dataspec</tt><tt class="py-op">)</tt> </tt>
<a name="L451"></a><tt class="py-lineno"> 451</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L452"></a><tt class="py-lineno"> 452</tt>  <tt class="py-line">            <tt class="py-keyword">return</tt> <tt class="py-name">dataspec</tt> </tt>
</div><a name="L453"></a><tt class="py-lineno"> 453</tt>  <tt class="py-line"> </tt>
<a name="Spharmt.spectogrd"></a><div id="Spharmt.spectogrd-def"><a name="L454"></a><tt class="py-lineno"> 454</tt> <a class="py-toggle" href="#" id="Spharmt.spectogrd-toggle" onclick="return toggle('Spharmt.spectogrd');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="spharm.spharm.Spharmt-class.html#spectogrd">spectogrd</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">dataspec</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Spharmt.spectogrd-collapsed" style="display:none;" pad="++++" indent="++++++++"></div><div id="Spharmt.spectogrd-expanded"><a name="L455"></a><tt class="py-lineno"> 455</tt>  <tt class="py-line"> </tt>
<a name="L456"></a><tt class="py-lineno"> 456</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L457"></a><tt class="py-lineno"> 457</tt>  <tt class="py-line"><tt class="py-docstring"> spectral to grid transform (spherical harmonic synthesis).</tt> </tt>
<a name="L458"></a><tt class="py-lineno"> 458</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L459"></a><tt class="py-lineno"> 459</tt>  <tt class="py-line"><tt class="py-docstring"> @param dataspec: rank 1 or 2 numpy complex array with shape</tt> </tt>
<a name="L460"></a><tt class="py-lineno"> 460</tt>  <tt class="py-line"><tt class="py-docstring"> (ntrunc+1)*(ntrunc+2)/2 or ((ntrunc+1)*(ntrunc+2)/2,nt) containing</tt> </tt>
<a name="L461"></a><tt class="py-lineno"> 461</tt>  <tt class="py-line"><tt class="py-docstring"> complex spherical harmonic coefficients (where ntrunc is the</tt> </tt>
<a name="L462"></a><tt class="py-lineno"> 462</tt>  <tt class="py-line"><tt class="py-docstring"> triangular truncation limit and nt is the number of spectral arrays</tt> </tt>
<a name="L463"></a><tt class="py-lineno"> 463</tt>  <tt class="py-line"><tt class="py-docstring"> to be transformed). If dataspec is rank 1, nt is assumed to be 1.</tt> </tt>
<a name="L464"></a><tt class="py-lineno"> 464</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L465"></a><tt class="py-lineno"> 465</tt>  <tt class="py-line"><tt class="py-docstring"> @return: C{B{datagrid}} - rank 2 or 3 numpy float32 array with shape</tt> </tt>
<a name="L466"></a><tt class="py-lineno"> 466</tt>  <tt class="py-line"><tt class="py-docstring"> (nlat,nlon) or (nlat,nlon,nt) containing the gridded data resulting from</tt> </tt>
<a name="L467"></a><tt class="py-lineno"> 467</tt>  <tt class="py-line"><tt class="py-docstring"> the spherical harmonic synthesis of dataspec.</tt> </tt>
<a name="L468"></a><tt class="py-lineno"> 468</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L469"></a><tt class="py-lineno"> 469</tt>  <tt class="py-line"> </tt>
<a name="L470"></a><tt class="py-lineno"> 470</tt>  <tt class="py-line"><tt class="py-comment"># make sure dataspec is rank 1 or 2.</tt> </tt>
<a name="L471"></a><tt class="py-lineno"> 471</tt>  <tt class="py-line"> </tt>
<a name="L472"></a><tt class="py-lineno"> 472</tt>  <tt class="py-line">        <tt class="py-name">idim</tt> <tt class="py-op">=</tt> <tt class="py-name">dataspec</tt><tt class="py-op">.</tt><tt class="py-name">ndim</tt> </tt>
<a name="L473"></a><tt class="py-lineno"> 473</tt>  <tt class="py-line"> </tt>
<a name="L474"></a><tt class="py-lineno"> 474</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">dataspec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt> <tt class="py-op">&gt;</tt> <tt class="py-number">2</tt><tt class="py-op">:</tt> </tt>
<a name="L475"></a><tt class="py-lineno"> 475</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'spectogrd needs a rank one or two array, got %d'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">dataspec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt><tt class="py-op">,</tt><tt class="py-op">)</tt> </tt>
<a name="L476"></a><tt class="py-lineno"> 476</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L477"></a><tt class="py-lineno"> 477</tt>  <tt class="py-line"> </tt>
<a name="L478"></a><tt class="py-lineno"> 478</tt>  <tt class="py-line">        <tt class="py-name">nlat</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt> </tt>
<a name="L479"></a><tt class="py-lineno"> 479</tt>  <tt class="py-line">        <tt class="py-name">nlon</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlon</tt> </tt>
<a name="L480"></a><tt class="py-lineno"> 480</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">nlat</tt><tt class="py-op">%</tt><tt class="py-number">2</tt><tt class="py-op">:</tt>                              <tt class="py-comment"># nlat is odd</tt> </tt>
<a name="L481"></a><tt class="py-lineno"> 481</tt>  <tt class="py-line">            <tt class="py-name">n2</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> </tt>
<a name="L482"></a><tt class="py-lineno"> 482</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L483"></a><tt class="py-lineno"> 483</tt>  <tt class="py-line">            <tt class="py-name">n2</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> </tt>
<a name="L484"></a><tt class="py-lineno"> 484</tt>  <tt class="py-line"> </tt>
<a name="L485"></a><tt class="py-lineno"> 485</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">dataspec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt> <tt class="py-op">==</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
<a name="L486"></a><tt class="py-lineno"> 486</tt>  <tt class="py-line">            <tt class="py-name">nt</tt> <tt class="py-op">=</tt> <tt class="py-number">1</tt> </tt>
<a name="L487"></a><tt class="py-lineno"> 487</tt>  <tt class="py-line">            <tt class="py-name">dataspec</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">reshape</tt><tt class="py-op">(</tt><tt class="py-name">dataspec</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">dataspec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">,</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L488"></a><tt class="py-lineno"> 488</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L489"></a><tt class="py-lineno"> 489</tt>  <tt class="py-line">            <tt class="py-name">nt</tt> <tt class="py-op">=</tt> <tt class="py-name">dataspec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
<a name="L490"></a><tt class="py-lineno"> 490</tt>  <tt class="py-line"> </tt>
<a name="L491"></a><tt class="py-lineno"> 491</tt>  <tt class="py-line">        <tt class="py-name">ntrunc</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-op">-</tt><tt class="py-number">1.5</tt> <tt class="py-op">+</tt> <tt class="py-number">0.5</tt><tt class="py-op">*</tt><tt class="py-name">math</tt><tt class="py-op">.</tt><tt class="py-name">sqrt</tt><tt class="py-op">(</tt><tt class="py-number">9.</tt><tt class="py-op">-</tt><tt class="py-number">8.</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-number">1.</tt><tt class="py-op">-</tt><tt class="py-name">dataspec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L492"></a><tt class="py-lineno"> 492</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">ntrunc</tt> <tt class="py-op">&gt;</tt> <tt class="py-name">nlat</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
<a name="L493"></a><tt class="py-lineno"> 493</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'ntrunc too large - can be max of %d, got %d'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">,</tt><tt class="py-name">ntrunc</tt><tt class="py-op">)</tt> </tt>
<a name="L494"></a><tt class="py-lineno"> 494</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L495"></a><tt class="py-lineno"> 495</tt>  <tt class="py-line"> </tt>
<a name="L496"></a><tt class="py-lineno"> 496</tt>  <tt class="py-line">        <tt class="py-name">a</tt><tt class="py-op">,</tt> <tt class="py-name">b</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">onedtotwod</tt><tt class="py-op">(</tt><tt class="py-name">dataspec</tt><tt class="py-op">,</tt><tt class="py-name">nlat</tt><tt class="py-op">)</tt> </tt>
<a name="L497"></a><tt class="py-lineno"> 497</tt>  <tt class="py-line"> </tt>
<a name="L498"></a><tt class="py-lineno"> 498</tt>  <tt class="py-line"><tt class="py-comment"># regular grid.</tt> </tt>
<a name="L499"></a><tt class="py-lineno"> 499</tt>  <tt class="py-line"> </tt>
<a name="L500"></a><tt class="py-lineno"> 500</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">gridtype</tt> <tt class="py-op">==</tt> <tt class="py-string">'regular'</tt><tt class="py-op">:</tt> </tt>
<a name="L501"></a><tt class="py-lineno"> 501</tt>  <tt class="py-line"> </tt>
<a name="L502"></a><tt class="py-lineno"> 502</tt>  <tt class="py-line"><tt class="py-comment"># do spectral to grid transform.</tt> </tt>
<a name="L503"></a><tt class="py-lineno"> 503</tt>  <tt class="py-line"> </tt>
<a name="L504"></a><tt class="py-lineno"> 504</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">legfunc</tt> <tt class="py-op">==</tt> <tt class="py-string">'stored'</tt><tt class="py-op">:</tt> </tt>
<a name="L505"></a><tt class="py-lineno"> 505</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">nt</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-name">nlon</tt> </tt>
<a name="L506"></a><tt class="py-lineno"> 506</tt>  <tt class="py-line">                <tt class="py-name">datagrid</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">shses</tt><tt class="py-op">(</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt><tt class="py-name">a</tt><tt class="py-op">,</tt><tt class="py-name">b</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wshses</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">)</tt> </tt>
<a name="L507"></a><tt class="py-lineno"> 507</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L508"></a><tt class="py-lineno"> 508</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to shses in Spharmt.spectogrd ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L509"></a><tt class="py-lineno"> 509</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L510"></a><tt class="py-lineno"> 510</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L511"></a><tt class="py-lineno"> 511</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nt</tt><tt class="py-op">*</tt><tt class="py-name">nlon</tt><tt class="py-op">+</tt><tt class="py-name">max</tt><tt class="py-op">(</tt><tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">,</tt><tt class="py-name">nlon</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L512"></a><tt class="py-lineno"> 512</tt>  <tt class="py-line">                <tt class="py-name">datagrid</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">shsec</tt><tt class="py-op">(</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt><tt class="py-name">a</tt><tt class="py-op">,</tt><tt class="py-name">b</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wshsec</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">)</tt> </tt>
<a name="L513"></a><tt class="py-lineno"> 513</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L514"></a><tt class="py-lineno"> 514</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to shsec in Spharmt.spectogrd ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L515"></a><tt class="py-lineno"> 515</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L516"></a><tt class="py-lineno"> 516</tt>  <tt class="py-line"> </tt>
<a name="L517"></a><tt class="py-lineno"> 517</tt>  <tt class="py-line"><tt class="py-comment"># gaussian grid.</tt> </tt>
<a name="L518"></a><tt class="py-lineno"> 518</tt>  <tt class="py-line"> </tt>
<a name="L519"></a><tt class="py-lineno"> 519</tt>  <tt class="py-line">        <tt class="py-keyword">elif</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">gridtype</tt> <tt class="py-op">==</tt> <tt class="py-string">'gaussian'</tt><tt class="py-op">:</tt> </tt>
<a name="L520"></a><tt class="py-lineno"> 520</tt>  <tt class="py-line"> </tt>
<a name="L521"></a><tt class="py-lineno"> 521</tt>  <tt class="py-line"><tt class="py-comment"># do spectral to grid transform.</tt> </tt>
<a name="L522"></a><tt class="py-lineno"> 522</tt>  <tt class="py-line"> </tt>
<a name="L523"></a><tt class="py-lineno"> 523</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">legfunc</tt> <tt class="py-op">==</tt> <tt class="py-string">'stored'</tt><tt class="py-op">:</tt> </tt>
<a name="L524"></a><tt class="py-lineno"> 524</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-name">nlon</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nt</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt> </tt>
<a name="L525"></a><tt class="py-lineno"> 525</tt>  <tt class="py-line">                <tt class="py-name">datagrid</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">shsgs</tt><tt class="py-op">(</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt><tt class="py-name">a</tt><tt class="py-op">,</tt><tt class="py-name">b</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wshsgs</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">)</tt> </tt>
<a name="L526"></a><tt class="py-lineno"> 526</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L527"></a><tt class="py-lineno"> 527</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to shsgs in Spharmt.spectogrd ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L528"></a><tt class="py-lineno"> 528</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L529"></a><tt class="py-lineno"> 529</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L530"></a><tt class="py-lineno"> 530</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">nlon</tt><tt class="py-op">*</tt><tt class="py-name">nt</tt><tt class="py-op">+</tt><tt class="py-name">max</tt><tt class="py-op">(</tt><tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">,</tt><tt class="py-name">nlon</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L531"></a><tt class="py-lineno"> 531</tt>  <tt class="py-line">                <tt class="py-name">datagrid</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">shsgc</tt><tt class="py-op">(</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt><tt class="py-name">a</tt><tt class="py-op">,</tt><tt class="py-name">b</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wshsgc</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">)</tt> </tt>
<a name="L532"></a><tt class="py-lineno"> 532</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L533"></a><tt class="py-lineno"> 533</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to shsgc in Spharmt.spectogrd ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L534"></a><tt class="py-lineno"> 534</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L535"></a><tt class="py-lineno"> 535</tt>  <tt class="py-line"> </tt>
<a name="L536"></a><tt class="py-lineno"> 536</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">idim</tt> <tt class="py-op">==</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
<a name="L537"></a><tt class="py-lineno"> 537</tt>  <tt class="py-line">            <tt class="py-keyword">return</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">squeeze</tt><tt class="py-op">(</tt><tt class="py-name">datagrid</tt><tt class="py-op">)</tt> </tt>
<a name="L538"></a><tt class="py-lineno"> 538</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L539"></a><tt class="py-lineno"> 539</tt>  <tt class="py-line">            <tt class="py-keyword">return</tt> <tt class="py-name">datagrid</tt> </tt>
</div><a name="L540"></a><tt class="py-lineno"> 540</tt>  <tt class="py-line"> </tt>
<a name="Spharmt.getvrtdivspec"></a><div id="Spharmt.getvrtdivspec-def"><a name="L541"></a><tt class="py-lineno"> 541</tt> <a class="py-toggle" href="#" id="Spharmt.getvrtdivspec-toggle" onclick="return toggle('Spharmt.getvrtdivspec');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="spharm.spharm.Spharmt-class.html#getvrtdivspec">getvrtdivspec</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">ugrid</tt><tt class="py-op">,</tt> <tt class="py-param">vgrid</tt><tt class="py-op">,</tt> <tt class="py-param">ntrunc</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Spharmt.getvrtdivspec-collapsed" style="display:none;" pad="++++" indent="++++++++"></div><div id="Spharmt.getvrtdivspec-expanded"><a name="L542"></a><tt class="py-lineno"> 542</tt>  <tt class="py-line"> </tt>
<a name="L543"></a><tt class="py-lineno"> 543</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L544"></a><tt class="py-lineno"> 544</tt>  <tt class="py-line"><tt class="py-docstring"> compute spectral coefficients of vorticity and divergence given vector wind.</tt> </tt>
<a name="L545"></a><tt class="py-lineno"> 545</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L546"></a><tt class="py-lineno"> 546</tt>  <tt class="py-line"><tt class="py-docstring"> @param ugrid: rank 2 or 3 numpy float32 array containing grid of zonal</tt> </tt>
<a name="L547"></a><tt class="py-lineno"> 547</tt>  <tt class="py-line"><tt class="py-docstring"> winds.  Must have shape (nlat,nlon) or (nlat,nlon,nt), where nt is the number</tt> </tt>
<a name="L548"></a><tt class="py-lineno"> 548</tt>  <tt class="py-line"><tt class="py-docstring"> of grids to be transformed.  If ugrid is rank 2, nt is assumed to be 1.</tt> </tt>
<a name="L549"></a><tt class="py-lineno"> 549</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L550"></a><tt class="py-lineno"> 550</tt>  <tt class="py-line"><tt class="py-docstring"> @param vgrid: rank 2 or 3 numpy float32 array containing grid of meridional</tt> </tt>
<a name="L551"></a><tt class="py-lineno"> 551</tt>  <tt class="py-line"><tt class="py-docstring"> winds.  Must have shape (nlat,nlon) or (nlat,nlon,nt), where nt is the number</tt> </tt>
<a name="L552"></a><tt class="py-lineno"> 552</tt>  <tt class="py-line"><tt class="py-docstring"> of grids to be transformed.  Both ugrid and vgrid must have the same shape.</tt> </tt>
<a name="L553"></a><tt class="py-lineno"> 553</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L554"></a><tt class="py-lineno"> 554</tt>  <tt class="py-line"><tt class="py-docstring"> @keyword ntrunc:  optional spectral truncation limit.</tt> </tt>
<a name="L555"></a><tt class="py-lineno"> 555</tt>  <tt class="py-line"><tt class="py-docstring"> (default self.nlat-1)</tt> </tt>
<a name="L556"></a><tt class="py-lineno"> 556</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L557"></a><tt class="py-lineno"> 557</tt>  <tt class="py-line"><tt class="py-docstring"> @return: C{B{vrtspec, divspec}} - rank 1 or 2 numpy complex arrays</tt> </tt>
<a name="L558"></a><tt class="py-lineno"> 558</tt>  <tt class="py-line"><tt class="py-docstring"> of vorticity and divergence spherical harmonic coefficients with shape</tt> </tt>
<a name="L559"></a><tt class="py-lineno"> 559</tt>  <tt class="py-line"><tt class="py-docstring"> shape (ntrunc+1)*(ntrunc+2)/2 or ((ntrunc+1)*(ntrunc+2)/2,nt).</tt> </tt>
<a name="L560"></a><tt class="py-lineno"> 560</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L561"></a><tt class="py-lineno"> 561</tt>  <tt class="py-line"> </tt>
<a name="L562"></a><tt class="py-lineno"> 562</tt>  <tt class="py-line"><tt class="py-comment"># make sure ugrid,vgrid are rank 2 or 3 and same shape.</tt> </tt>
<a name="L563"></a><tt class="py-lineno"> 563</tt>  <tt class="py-line"> </tt>
<a name="L564"></a><tt class="py-lineno"> 564</tt>  <tt class="py-line">        <tt class="py-name">idim</tt> <tt class="py-op">=</tt> <tt class="py-name">ugrid</tt><tt class="py-op">.</tt><tt class="py-name">ndim</tt> </tt>
<a name="L565"></a><tt class="py-lineno"> 565</tt>  <tt class="py-line"> </tt>
<a name="L566"></a><tt class="py-lineno"> 566</tt>  <tt class="py-line">        <tt class="py-name">shapeu</tt> <tt class="py-op">=</tt> <tt class="py-name">ugrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt> </tt>
<a name="L567"></a><tt class="py-lineno"> 567</tt>  <tt class="py-line">        <tt class="py-name">shapev</tt> <tt class="py-op">=</tt> <tt class="py-name">vgrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt> </tt>
<a name="L568"></a><tt class="py-lineno"> 568</tt>  <tt class="py-line"> </tt>
<a name="L569"></a><tt class="py-lineno"> 569</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">ntrunc</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
<a name="L570"></a><tt class="py-lineno"> 570</tt>  <tt class="py-line">            <tt class="py-name">ntrunc</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt><tt class="py-op">-</tt><tt class="py-number">1</tt> </tt>
<a name="L571"></a><tt class="py-lineno"> 571</tt>  <tt class="py-line"> </tt>
<a name="L572"></a><tt class="py-lineno"> 572</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">shapeu</tt> <tt class="py-op">!=</tt> <tt class="py-name">shapev</tt><tt class="py-op">:</tt> </tt>
<a name="L573"></a><tt class="py-lineno"> 573</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'getvrtdivspec input arrays must be same shape!'</tt> </tt>
<a name="L574"></a><tt class="py-lineno"> 574</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L575"></a><tt class="py-lineno"> 575</tt>  <tt class="py-line"> </tt>
<a name="L576"></a><tt class="py-lineno"> 576</tt>  <tt class="py-line"> </tt>
<a name="L577"></a><tt class="py-lineno"> 577</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">shapeu</tt><tt class="py-op">)</tt> <tt class="py-op">!=</tt><tt class="py-number">2</tt> <tt class="py-keyword">and</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">shapeu</tt><tt class="py-op">)</tt> <tt class="py-op">!=</tt><tt class="py-number">3</tt><tt class="py-op">:</tt> </tt>
<a name="L578"></a><tt class="py-lineno"> 578</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'getvrtdivspec needs rank two or three arrays!'</tt> </tt>
<a name="L579"></a><tt class="py-lineno"> 579</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L580"></a><tt class="py-lineno"> 580</tt>  <tt class="py-line"> </tt>
<a name="L581"></a><tt class="py-lineno"> 581</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">shapeu</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt> <tt class="py-keyword">or</tt> <tt class="py-name">shapeu</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlon</tt><tt class="py-op">:</tt> </tt>
<a name="L582"></a><tt class="py-lineno"> 582</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'getvrtdivspec needs input arrays whose first two dimensions are si%d and %d, got %d and %d'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">ugrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-name">ugrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">,</tt><tt class="py-op">)</tt> </tt>
<a name="L583"></a><tt class="py-lineno"> 583</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L584"></a><tt class="py-lineno"> 584</tt>  <tt class="py-line"> </tt>
<a name="L585"></a><tt class="py-lineno"> 585</tt>  <tt class="py-line"> </tt>
<a name="L586"></a><tt class="py-lineno"> 586</tt>  <tt class="py-line"><tt class="py-comment"># check ntrunc.</tt> </tt>
<a name="L587"></a><tt class="py-lineno"> 587</tt>  <tt class="py-line"> </tt>
<a name="L588"></a><tt class="py-lineno"> 588</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">ntrunc</tt> <tt class="py-op">&lt;</tt> <tt class="py-number">0</tt> <tt class="py-keyword">or</tt> <tt class="py-name">ntrunc</tt><tt class="py-op">+</tt><tt class="py-number">1</tt> <tt class="py-op">&gt;</tt> <tt class="py-name">shapeu</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">:</tt> </tt>
<a name="L589"></a><tt class="py-lineno"> 589</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'ntrunc must be between 0 and %d'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">ugrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">,</tt><tt class="py-op">)</tt> </tt>
<a name="L590"></a><tt class="py-lineno"> 590</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L591"></a><tt class="py-lineno"> 591</tt>  <tt class="py-line"> </tt>
<a name="L592"></a><tt class="py-lineno"> 592</tt>  <tt class="py-line">        <tt class="py-name">nlat</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt> </tt>
<a name="L593"></a><tt class="py-lineno"> 593</tt>  <tt class="py-line">        <tt class="py-name">nlon</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlon</tt> </tt>
<a name="L594"></a><tt class="py-lineno"> 594</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">nlat</tt><tt class="py-op">%</tt><tt class="py-number">2</tt><tt class="py-op">:</tt>                              <tt class="py-comment"># nlat is odd</tt> </tt>
<a name="L595"></a><tt class="py-lineno"> 595</tt>  <tt class="py-line">            <tt class="py-name">n2</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> </tt>
<a name="L596"></a><tt class="py-lineno"> 596</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L597"></a><tt class="py-lineno"> 597</tt>  <tt class="py-line">            <tt class="py-name">n2</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> </tt>
<a name="L598"></a><tt class="py-lineno"> 598</tt>  <tt class="py-line">        <tt class="py-name">rsphere</tt><tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">rsphere</tt> </tt>
<a name="L599"></a><tt class="py-lineno"> 599</tt>  <tt class="py-line"> </tt>
<a name="L600"></a><tt class="py-lineno"> 600</tt>  <tt class="py-line"><tt class="py-comment"># convert from geographical to math coordinates, add extra dimension</tt> </tt>
<a name="L601"></a><tt class="py-lineno"> 601</tt>  <tt class="py-line"><tt class="py-comment"># if necessary.</tt> </tt>
<a name="L602"></a><tt class="py-lineno"> 602</tt>  <tt class="py-line"> </tt>
<a name="L603"></a><tt class="py-lineno"> 603</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">shapeu</tt><tt class="py-op">)</tt> <tt class="py-op">==</tt> <tt class="py-number">2</tt><tt class="py-op">:</tt> </tt>
<a name="L604"></a><tt class="py-lineno"> 604</tt>  <tt class="py-line">            <tt class="py-name">nt</tt> <tt class="py-op">=</tt> <tt class="py-number">1</tt> </tt>
<a name="L605"></a><tt class="py-lineno"> 605</tt>  <tt class="py-line">            <tt class="py-name">w</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">reshape</tt><tt class="py-op">(</tt><tt class="py-name">ugrid</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L606"></a><tt class="py-lineno"> 606</tt>  <tt class="py-line">            <tt class="py-name">v</tt> <tt class="py-op">=</tt> <tt class="py-op">-</tt><tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">reshape</tt><tt class="py-op">(</tt><tt class="py-name">vgrid</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L607"></a><tt class="py-lineno"> 607</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L608"></a><tt class="py-lineno"> 608</tt>  <tt class="py-line">            <tt class="py-name">nt</tt> <tt class="py-op">=</tt> <tt class="py-name">shapeu</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">]</tt> </tt>
<a name="L609"></a><tt class="py-lineno"> 609</tt>  <tt class="py-line">            <tt class="py-name">w</tt> <tt class="py-op">=</tt> <tt class="py-name">ugrid</tt> </tt>
<a name="L610"></a><tt class="py-lineno"> 610</tt>  <tt class="py-line">            <tt class="py-name">v</tt> <tt class="py-op">=</tt> <tt class="py-op">-</tt><tt class="py-name">vgrid</tt> </tt>
<a name="L611"></a><tt class="py-lineno"> 611</tt>  <tt class="py-line"> </tt>
<a name="L612"></a><tt class="py-lineno"> 612</tt>  <tt class="py-line"><tt class="py-comment"># regular grid.</tt> </tt>
<a name="L613"></a><tt class="py-lineno"> 613</tt>  <tt class="py-line"> </tt>
<a name="L614"></a><tt class="py-lineno"> 614</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">gridtype</tt> <tt class="py-op">==</tt> <tt class="py-string">'regular'</tt><tt class="py-op">:</tt> </tt>
<a name="L615"></a><tt class="py-lineno"> 615</tt>  <tt class="py-line"> </tt>
<a name="L616"></a><tt class="py-lineno"> 616</tt>  <tt class="py-line"><tt class="py-comment"># vector harmonic analysis.</tt> </tt>
<a name="L617"></a><tt class="py-lineno"> 617</tt>  <tt class="py-line"> </tt>
<a name="L618"></a><tt class="py-lineno"> 618</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">legfunc</tt> <tt class="py-op">==</tt> <tt class="py-string">'stored'</tt><tt class="py-op">:</tt> </tt>
<a name="L619"></a><tt class="py-lineno"> 619</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">nt</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-name">nlon</tt> </tt>
<a name="L620"></a><tt class="py-lineno"> 620</tt>  <tt class="py-line">                <tt class="py-name">br</tt><tt class="py-op">,</tt><tt class="py-name">bi</tt><tt class="py-op">,</tt><tt class="py-name">cr</tt><tt class="py-op">,</tt><tt class="py-name">ci</tt><tt class="py-op">,</tt><tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">vhaes</tt><tt class="py-op">(</tt><tt class="py-name">v</tt><tt class="py-op">,</tt><tt class="py-name">w</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wvhaes</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">)</tt> </tt>
<a name="L621"></a><tt class="py-lineno"> 621</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L622"></a><tt class="py-lineno"> 622</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to vhaes in Spharmt.getvrtdivspec ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L623"></a><tt class="py-lineno"> 623</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L624"></a><tt class="py-lineno"> 624</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L625"></a><tt class="py-lineno"> 625</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">nt</tt><tt class="py-op">*</tt><tt class="py-name">nlon</tt><tt class="py-op">+</tt><tt class="py-name">max</tt><tt class="py-op">(</tt><tt class="py-number">6</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">,</tt><tt class="py-name">nlon</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L626"></a><tt class="py-lineno"> 626</tt>  <tt class="py-line">                <tt class="py-name">br</tt><tt class="py-op">,</tt><tt class="py-name">bi</tt><tt class="py-op">,</tt><tt class="py-name">cr</tt><tt class="py-op">,</tt><tt class="py-name">ci</tt><tt class="py-op">,</tt><tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">vhaec</tt><tt class="py-op">(</tt><tt class="py-name">v</tt><tt class="py-op">,</tt><tt class="py-name">w</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wvhaec</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">)</tt> </tt>
<a name="L627"></a><tt class="py-lineno"> 627</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L628"></a><tt class="py-lineno"> 628</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to vhaec in Spharmt.getvrtdivspec ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L629"></a><tt class="py-lineno"> 629</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L630"></a><tt class="py-lineno"> 630</tt>  <tt class="py-line"> </tt>
<a name="L631"></a><tt class="py-lineno"> 631</tt>  <tt class="py-line"><tt class="py-comment"># gaussian grid.</tt> </tt>
<a name="L632"></a><tt class="py-lineno"> 632</tt>  <tt class="py-line"> </tt>
<a name="L633"></a><tt class="py-lineno"> 633</tt>  <tt class="py-line">        <tt class="py-keyword">elif</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">gridtype</tt> <tt class="py-op">==</tt> <tt class="py-string">'gaussian'</tt><tt class="py-op">:</tt> </tt>
<a name="L634"></a><tt class="py-lineno"> 634</tt>  <tt class="py-line"> </tt>
<a name="L635"></a><tt class="py-lineno"> 635</tt>  <tt class="py-line"><tt class="py-comment"># vector harmonic analysis.</tt> </tt>
<a name="L636"></a><tt class="py-lineno"> 636</tt>  <tt class="py-line"> </tt>
<a name="L637"></a><tt class="py-lineno"> 637</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">legfunc</tt> <tt class="py-op">==</tt> <tt class="py-string">'stored'</tt><tt class="py-op">:</tt> </tt>
<a name="L638"></a><tt class="py-lineno"> 638</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">nt</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-name">nlon</tt> </tt>
<a name="L639"></a><tt class="py-lineno"> 639</tt>  <tt class="py-line">                <tt class="py-name">br</tt><tt class="py-op">,</tt><tt class="py-name">bi</tt><tt class="py-op">,</tt><tt class="py-name">cr</tt><tt class="py-op">,</tt><tt class="py-name">ci</tt><tt class="py-op">,</tt><tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">vhags</tt><tt class="py-op">(</tt><tt class="py-name">v</tt><tt class="py-op">,</tt><tt class="py-name">w</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wvhags</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">)</tt> </tt>
<a name="L640"></a><tt class="py-lineno"> 640</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L641"></a><tt class="py-lineno"> 641</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to vhags in Spharmt.getvrtdivspec ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L642"></a><tt class="py-lineno"> 642</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L643"></a><tt class="py-lineno"> 643</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L644"></a><tt class="py-lineno"> 644</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">nlon</tt><tt class="py-op">*</tt><tt class="py-name">nt</tt><tt class="py-op">+</tt><tt class="py-number">3</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">)</tt> </tt>
<a name="L645"></a><tt class="py-lineno"> 645</tt>  <tt class="py-line">                <tt class="py-name">br</tt><tt class="py-op">,</tt><tt class="py-name">bi</tt><tt class="py-op">,</tt><tt class="py-name">cr</tt><tt class="py-op">,</tt><tt class="py-name">ci</tt><tt class="py-op">,</tt><tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">vhagc</tt><tt class="py-op">(</tt><tt class="py-name">v</tt><tt class="py-op">,</tt><tt class="py-name">w</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wvhagc</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">)</tt> </tt>
<a name="L646"></a><tt class="py-lineno"> 646</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L647"></a><tt class="py-lineno"> 647</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to vhagc in Spharmt.getvrtdivspec ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L648"></a><tt class="py-lineno"> 648</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L649"></a><tt class="py-lineno"> 649</tt>  <tt class="py-line"> </tt>
<a name="L650"></a><tt class="py-lineno"> 650</tt>  <tt class="py-line"><tt class="py-comment"># convert vector harmonic coeffs to 1d complex coefficients</tt> </tt>
<a name="L651"></a><tt class="py-lineno"> 651</tt>  <tt class="py-line"><tt class="py-comment"># of vorticity and divergence.</tt> </tt>
<a name="L652"></a><tt class="py-lineno"> 652</tt>  <tt class="py-line"> </tt>
<a name="L653"></a><tt class="py-lineno"> 653</tt>  <tt class="py-line">        <tt class="py-name">vrtspec</tt><tt class="py-op">,</tt> <tt class="py-name">divspec</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">twodtooned_vrtdiv</tt><tt class="py-op">(</tt><tt class="py-name">br</tt><tt class="py-op">,</tt><tt class="py-name">bi</tt><tt class="py-op">,</tt><tt class="py-name">cr</tt><tt class="py-op">,</tt><tt class="py-name">ci</tt><tt class="py-op">,</tt><tt class="py-name">ntrunc</tt><tt class="py-op">,</tt><tt class="py-name">rsphere</tt><tt class="py-op">)</tt> </tt>
<a name="L654"></a><tt class="py-lineno"> 654</tt>  <tt class="py-line"> </tt>
<a name="L655"></a><tt class="py-lineno"> 655</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">idim</tt> <tt class="py-op">==</tt> <tt class="py-number">2</tt><tt class="py-op">:</tt> </tt>
<a name="L656"></a><tt class="py-lineno"> 656</tt>  <tt class="py-line">            <tt class="py-keyword">return</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">squeeze</tt><tt class="py-op">(</tt><tt class="py-name">vrtspec</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">squeeze</tt><tt class="py-op">(</tt><tt class="py-name">divspec</tt><tt class="py-op">)</tt> </tt>
<a name="L657"></a><tt class="py-lineno"> 657</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L658"></a><tt class="py-lineno"> 658</tt>  <tt class="py-line">            <tt class="py-keyword">return</tt> <tt class="py-name">vrtspec</tt><tt class="py-op">,</tt> <tt class="py-name">divspec</tt> </tt>
</div><a name="L659"></a><tt class="py-lineno"> 659</tt>  <tt class="py-line"> </tt>
<a name="Spharmt.getuv"></a><div id="Spharmt.getuv-def"><a name="L660"></a><tt class="py-lineno"> 660</tt> <a class="py-toggle" href="#" id="Spharmt.getuv-toggle" onclick="return toggle('Spharmt.getuv');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="spharm.spharm.Spharmt-class.html#getuv">getuv</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">vrtspec</tt><tt class="py-op">,</tt> <tt class="py-param">divspec</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Spharmt.getuv-collapsed" style="display:none;" pad="++++" indent="++++++++"></div><div id="Spharmt.getuv-expanded"><a name="L661"></a><tt class="py-lineno"> 661</tt>  <tt class="py-line"> </tt>
<a name="L662"></a><tt class="py-lineno"> 662</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L663"></a><tt class="py-lineno"> 663</tt>  <tt class="py-line"><tt class="py-docstring"> compute vector wind on grid given complex spectral coefficients</tt> </tt>
<a name="L664"></a><tt class="py-lineno"> 664</tt>  <tt class="py-line"><tt class="py-docstring"> of vorticity and divergence.</tt> </tt>
<a name="L665"></a><tt class="py-lineno"> 665</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L666"></a><tt class="py-lineno"> 666</tt>  <tt class="py-line"><tt class="py-docstring"> @param vrtspec: rank 1 or 2 numpy complex array of vorticity spectral</tt> </tt>
<a name="L667"></a><tt class="py-lineno"> 667</tt>  <tt class="py-line"><tt class="py-docstring"> coefficients, with shape (ntrunc+1)*(ntrunc+2)/2 or</tt> </tt>
<a name="L668"></a><tt class="py-lineno"> 668</tt>  <tt class="py-line"><tt class="py-docstring"> ((ntrunc+1)*(ntrunc+2)/2,nt) (where ntrunc is the triangular truncation</tt> </tt>
<a name="L669"></a><tt class="py-lineno"> 669</tt>  <tt class="py-line"><tt class="py-docstring"> and nt is the number of spectral arrays to be transformed).</tt> </tt>
<a name="L670"></a><tt class="py-lineno"> 670</tt>  <tt class="py-line"><tt class="py-docstring"> If vrtspec is rank 1, nt is assumed to be 1.</tt> </tt>
<a name="L671"></a><tt class="py-lineno"> 671</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L672"></a><tt class="py-lineno"> 672</tt>  <tt class="py-line"><tt class="py-docstring"> @param divspec: rank 1 or 2 numpy complex array of divergence spectral</tt> </tt>
<a name="L673"></a><tt class="py-lineno"> 673</tt>  <tt class="py-line"><tt class="py-docstring"> coefficients, with shape (ntrunc+1)*(ntrunc+2)/2 or</tt> </tt>
<a name="L674"></a><tt class="py-lineno"> 674</tt>  <tt class="py-line"><tt class="py-docstring"> ((ntrunc+1)*(ntrunc+2)/2,nt) (where ntrunc is the triangular truncation</tt> </tt>
<a name="L675"></a><tt class="py-lineno"> 675</tt>  <tt class="py-line"><tt class="py-docstring"> and nt is the number of spectral arrays to be transformed).</tt> </tt>
<a name="L676"></a><tt class="py-lineno"> 676</tt>  <tt class="py-line"><tt class="py-docstring"> Both vrtspec and divspec must have the same shape.</tt> </tt>
<a name="L677"></a><tt class="py-lineno"> 677</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L678"></a><tt class="py-lineno"> 678</tt>  <tt class="py-line"><tt class="py-docstring"> @return: C{B{ugrid, vgrid}} - rank 2 or 3 numpy float32 arrays containing</tt> </tt>
<a name="L679"></a><tt class="py-lineno"> 679</tt>  <tt class="py-line"><tt class="py-docstring"> gridded zonal and meridional winds. Shapes are either (nlat,nlon) or</tt> </tt>
<a name="L680"></a><tt class="py-lineno"> 680</tt>  <tt class="py-line"><tt class="py-docstring"> (nlat,nlon,nt).</tt> </tt>
<a name="L681"></a><tt class="py-lineno"> 681</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L682"></a><tt class="py-lineno"> 682</tt>  <tt class="py-line"> </tt>
<a name="L683"></a><tt class="py-lineno"> 683</tt>  <tt class="py-line">        <tt class="py-name">idim</tt> <tt class="py-op">=</tt> <tt class="py-name">vrtspec</tt><tt class="py-op">.</tt><tt class="py-name">ndim</tt> </tt>
<a name="L684"></a><tt class="py-lineno"> 684</tt>  <tt class="py-line"> </tt>
<a name="L685"></a><tt class="py-lineno"> 685</tt>  <tt class="py-line">        <tt class="py-name">shapevrt</tt> <tt class="py-op">=</tt> <tt class="py-name">vrtspec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt> </tt>
<a name="L686"></a><tt class="py-lineno"> 686</tt>  <tt class="py-line">        <tt class="py-name">shapediv</tt> <tt class="py-op">=</tt> <tt class="py-name">divspec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt> </tt>
<a name="L687"></a><tt class="py-lineno"> 687</tt>  <tt class="py-line"> </tt>
<a name="L688"></a><tt class="py-lineno"> 688</tt>  <tt class="py-line"><tt class="py-comment"># make sure vrtspec, divspec are rank 1 or 2, and have the same shape.</tt> </tt>
<a name="L689"></a><tt class="py-lineno"> 689</tt>  <tt class="py-line"> </tt>
<a name="L690"></a><tt class="py-lineno"> 690</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">shapevrt</tt> <tt class="py-op">!=</tt> <tt class="py-name">shapediv</tt><tt class="py-op">:</tt> </tt>
<a name="L691"></a><tt class="py-lineno"> 691</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'vrtspec, divspec must be same size in getuv!'</tt> </tt>
<a name="L692"></a><tt class="py-lineno"> 692</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L693"></a><tt class="py-lineno"> 693</tt>  <tt class="py-line"> </tt>
<a name="L694"></a><tt class="py-lineno"> 694</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">shapevrt</tt><tt class="py-op">)</tt> <tt class="py-op">!=</tt><tt class="py-number">1</tt> <tt class="py-keyword">and</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">shapevrt</tt><tt class="py-op">)</tt> <tt class="py-op">!=</tt><tt class="py-number">2</tt><tt class="py-op">:</tt> </tt>
<a name="L695"></a><tt class="py-lineno"> 695</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'getuv needs rank one or two input arrays!'</tt> </tt>
<a name="L696"></a><tt class="py-lineno"> 696</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L697"></a><tt class="py-lineno"> 697</tt>  <tt class="py-line"> </tt>
<a name="L698"></a><tt class="py-lineno"> 698</tt>  <tt class="py-line"><tt class="py-comment"># infer ntrunc from size of dataspec (dataspec must be rank 1!)</tt> </tt>
<a name="L699"></a><tt class="py-lineno"> 699</tt>  <tt class="py-line"><tt class="py-comment"># dataspec is assumed to have size (ntrunc+1)*(ntrunc+2)/2</tt> </tt>
<a name="L700"></a><tt class="py-lineno"> 700</tt>  <tt class="py-line"> </tt>
<a name="L701"></a><tt class="py-lineno"> 701</tt>  <tt class="py-line">        <tt class="py-name">ntrunc</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-op">-</tt><tt class="py-number">1.5</tt> <tt class="py-op">+</tt> <tt class="py-number">0.5</tt><tt class="py-op">*</tt><tt class="py-name">math</tt><tt class="py-op">.</tt><tt class="py-name">sqrt</tt><tt class="py-op">(</tt><tt class="py-number">9.</tt><tt class="py-op">-</tt><tt class="py-number">8.</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-number">1.</tt><tt class="py-op">-</tt><tt class="py-name">vrtspec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L702"></a><tt class="py-lineno"> 702</tt>  <tt class="py-line"> </tt>
<a name="L703"></a><tt class="py-lineno"> 703</tt>  <tt class="py-line">        <tt class="py-name">nlat</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt> </tt>
<a name="L704"></a><tt class="py-lineno"> 704</tt>  <tt class="py-line">        <tt class="py-name">nlon</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlon</tt> </tt>
<a name="L705"></a><tt class="py-lineno"> 705</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">nlat</tt><tt class="py-op">%</tt><tt class="py-number">2</tt><tt class="py-op">:</tt>                              <tt class="py-comment"># nlat is odd</tt> </tt>
<a name="L706"></a><tt class="py-lineno"> 706</tt>  <tt class="py-line">            <tt class="py-name">n2</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">nlat</tt> <tt class="py-op">+</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> </tt>
<a name="L707"></a><tt class="py-lineno"> 707</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L708"></a><tt class="py-lineno"> 708</tt>  <tt class="py-line">            <tt class="py-name">n2</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">/</tt><tt class="py-number">2</tt> </tt>
<a name="L709"></a><tt class="py-lineno"> 709</tt>  <tt class="py-line">        <tt class="py-name">rsphere</tt><tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">rsphere</tt> </tt>
<a name="L710"></a><tt class="py-lineno"> 710</tt>  <tt class="py-line"> </tt>
<a name="L711"></a><tt class="py-lineno"> 711</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">vrtspec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt> <tt class="py-op">==</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
<a name="L712"></a><tt class="py-lineno"> 712</tt>  <tt class="py-line">            <tt class="py-name">nt</tt> <tt class="py-op">=</tt> <tt class="py-number">1</tt> </tt>
<a name="L713"></a><tt class="py-lineno"> 713</tt>  <tt class="py-line">            <tt class="py-name">vrtspec</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">reshape</tt><tt class="py-op">(</tt><tt class="py-name">vrtspec</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">vrtspec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">,</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L714"></a><tt class="py-lineno"> 714</tt>  <tt class="py-line">            <tt class="py-name">divspec</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">reshape</tt><tt class="py-op">(</tt><tt class="py-name">divspec</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">divspec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">,</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L715"></a><tt class="py-lineno"> 715</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L716"></a><tt class="py-lineno"> 716</tt>  <tt class="py-line">            <tt class="py-name">nt</tt> <tt class="py-op">=</tt> <tt class="py-name">vrtspec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
<a name="L717"></a><tt class="py-lineno"> 717</tt>  <tt class="py-line"> </tt>
<a name="L718"></a><tt class="py-lineno"> 718</tt>  <tt class="py-line"><tt class="py-comment"># convert 1d complex arrays of vort, div to 2d vector harmonic arrays.</tt> </tt>
<a name="L719"></a><tt class="py-lineno"> 719</tt>  <tt class="py-line"> </tt>
<a name="L720"></a><tt class="py-lineno"> 720</tt>  <tt class="py-line">        <tt class="py-name">br</tt><tt class="py-op">,</tt><tt class="py-name">bi</tt><tt class="py-op">,</tt><tt class="py-name">cr</tt><tt class="py-op">,</tt><tt class="py-name">ci</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">onedtotwod_vrtdiv</tt><tt class="py-op">(</tt><tt class="py-name">vrtspec</tt><tt class="py-op">,</tt><tt class="py-name">divspec</tt><tt class="py-op">,</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt><tt class="py-name">rsphere</tt><tt class="py-op">)</tt> </tt>
<a name="L721"></a><tt class="py-lineno"> 721</tt>  <tt class="py-line"> </tt>
<a name="L722"></a><tt class="py-lineno"> 722</tt>  <tt class="py-line"><tt class="py-comment"># regular grid.</tt> </tt>
<a name="L723"></a><tt class="py-lineno"> 723</tt>  <tt class="py-line"> </tt>
<a name="L724"></a><tt class="py-lineno"> 724</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">gridtype</tt> <tt class="py-op">==</tt> <tt class="py-string">'regular'</tt><tt class="py-op">:</tt> </tt>
<a name="L725"></a><tt class="py-lineno"> 725</tt>  <tt class="py-line"> </tt>
<a name="L726"></a><tt class="py-lineno"> 726</tt>  <tt class="py-line"><tt class="py-comment"># vector harmonic synthesis.</tt> </tt>
<a name="L727"></a><tt class="py-lineno"> 727</tt>  <tt class="py-line"> </tt>
<a name="L728"></a><tt class="py-lineno"> 728</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">legfunc</tt> <tt class="py-op">==</tt> <tt class="py-string">'stored'</tt><tt class="py-op">:</tt> </tt>
<a name="L729"></a><tt class="py-lineno"> 729</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">nt</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-name">nlon</tt> </tt>
<a name="L730"></a><tt class="py-lineno"> 730</tt>  <tt class="py-line">                <tt class="py-name">v</tt><tt class="py-op">,</tt> <tt class="py-name">w</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">vhses</tt><tt class="py-op">(</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt><tt class="py-name">br</tt><tt class="py-op">,</tt><tt class="py-name">bi</tt><tt class="py-op">,</tt><tt class="py-name">cr</tt><tt class="py-op">,</tt><tt class="py-name">ci</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wvhses</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">)</tt> </tt>
<a name="L731"></a><tt class="py-lineno"> 731</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L732"></a><tt class="py-lineno"> 732</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to vhses in Spharmt.getuv ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L733"></a><tt class="py-lineno"> 733</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L734"></a><tt class="py-lineno"> 734</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L735"></a><tt class="py-lineno"> 735</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">nt</tt><tt class="py-op">*</tt><tt class="py-name">nlon</tt><tt class="py-op">+</tt><tt class="py-name">max</tt><tt class="py-op">(</tt><tt class="py-number">6</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">,</tt><tt class="py-name">nlon</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L736"></a><tt class="py-lineno"> 736</tt>  <tt class="py-line">                <tt class="py-name">v</tt><tt class="py-op">,</tt> <tt class="py-name">w</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">vhsec</tt><tt class="py-op">(</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt><tt class="py-name">br</tt><tt class="py-op">,</tt><tt class="py-name">bi</tt><tt class="py-op">,</tt><tt class="py-name">cr</tt><tt class="py-op">,</tt><tt class="py-name">ci</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wvhsec</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">)</tt> </tt>
<a name="L737"></a><tt class="py-lineno"> 737</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L738"></a><tt class="py-lineno"> 738</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to vhsec in Spharmt.getuv ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L739"></a><tt class="py-lineno"> 739</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L740"></a><tt class="py-lineno"> 740</tt>  <tt class="py-line"> </tt>
<a name="L741"></a><tt class="py-lineno"> 741</tt>  <tt class="py-line"><tt class="py-comment"># gaussian grid.</tt> </tt>
<a name="L742"></a><tt class="py-lineno"> 742</tt>  <tt class="py-line"> </tt>
<a name="L743"></a><tt class="py-lineno"> 743</tt>  <tt class="py-line">        <tt class="py-keyword">elif</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">gridtype</tt> <tt class="py-op">==</tt> <tt class="py-string">'gaussian'</tt><tt class="py-op">:</tt> </tt>
<a name="L744"></a><tt class="py-lineno"> 744</tt>  <tt class="py-line"> </tt>
<a name="L745"></a><tt class="py-lineno"> 745</tt>  <tt class="py-line"><tt class="py-comment"># vector harmonic synthesis.</tt> </tt>
<a name="L746"></a><tt class="py-lineno"> 746</tt>  <tt class="py-line"> </tt>
<a name="L747"></a><tt class="py-lineno"> 747</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">legfunc</tt> <tt class="py-op">==</tt> <tt class="py-string">'stored'</tt><tt class="py-op">:</tt> </tt>
<a name="L748"></a><tt class="py-lineno"> 748</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">nt</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-name">nlon</tt> </tt>
<a name="L749"></a><tt class="py-lineno"> 749</tt>  <tt class="py-line">                <tt class="py-name">v</tt><tt class="py-op">,</tt> <tt class="py-name">w</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">vhsgs</tt><tt class="py-op">(</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt><tt class="py-name">br</tt><tt class="py-op">,</tt><tt class="py-name">bi</tt><tt class="py-op">,</tt><tt class="py-name">cr</tt><tt class="py-op">,</tt><tt class="py-name">ci</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wvhsgs</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">)</tt> </tt>
<a name="L750"></a><tt class="py-lineno"> 750</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L751"></a><tt class="py-lineno"> 751</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to vhsgs in Spharmt.getuv ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L752"></a><tt class="py-lineno"> 752</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L753"></a><tt class="py-lineno"> 753</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L754"></a><tt class="py-lineno"> 754</tt>  <tt class="py-line">                <tt class="py-name">lwork</tt> <tt class="py-op">=</tt> <tt class="py-name">nlat</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-name">nt</tt><tt class="py-op">*</tt><tt class="py-name">nlon</tt><tt class="py-op">+</tt><tt class="py-name">max</tt><tt class="py-op">(</tt><tt class="py-number">6</tt><tt class="py-op">*</tt><tt class="py-name">n2</tt><tt class="py-op">,</tt><tt class="py-name">nlon</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L755"></a><tt class="py-lineno"> 755</tt>  <tt class="py-line">                <tt class="py-name">v</tt><tt class="py-op">,</tt> <tt class="py-name">w</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">vhsgc</tt><tt class="py-op">(</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt><tt class="py-name">br</tt><tt class="py-op">,</tt><tt class="py-name">bi</tt><tt class="py-op">,</tt><tt class="py-name">cr</tt><tt class="py-op">,</tt><tt class="py-name">ci</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">wvhsgc</tt><tt class="py-op">,</tt><tt class="py-name">lwork</tt><tt class="py-op">)</tt> </tt>
<a name="L756"></a><tt class="py-lineno"> 756</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L757"></a><tt class="py-lineno"> 757</tt>  <tt class="py-line">                    <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to vhsgc in Spharmt.getuv ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L758"></a><tt class="py-lineno"> 758</tt>  <tt class="py-line">                    <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L759"></a><tt class="py-lineno"> 759</tt>  <tt class="py-line"> </tt>
<a name="L760"></a><tt class="py-lineno"> 760</tt>  <tt class="py-line"><tt class="py-comment"># convert to u and v in geographical coordinates.</tt> </tt>
<a name="L761"></a><tt class="py-lineno"> 761</tt>  <tt class="py-line"> </tt>
<a name="L762"></a><tt class="py-lineno"> 762</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">idim</tt> <tt class="py-op">==</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
<a name="L763"></a><tt class="py-lineno"> 763</tt>  <tt class="py-line">            <tt class="py-keyword">return</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">reshape</tt><tt class="py-op">(</tt><tt class="py-name">w</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt><tt class="py-name">nlon</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt class="py-op">-</tt><tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">reshape</tt><tt class="py-op">(</tt><tt class="py-name">v</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt><tt class="py-name">nlon</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L764"></a><tt class="py-lineno"> 764</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L765"></a><tt class="py-lineno"> 765</tt>  <tt class="py-line">            <tt class="py-keyword">return</tt> <tt class="py-name">w</tt><tt class="py-op">,</tt><tt class="py-op">-</tt><tt class="py-name">v</tt> </tt>
</div><a name="L766"></a><tt class="py-lineno"> 766</tt>  <tt class="py-line"> </tt>
<a name="Spharmt.getpsichi"></a><div id="Spharmt.getpsichi-def"><a name="L767"></a><tt class="py-lineno"> 767</tt> <a class="py-toggle" href="#" id="Spharmt.getpsichi-toggle" onclick="return toggle('Spharmt.getpsichi');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="spharm.spharm.Spharmt-class.html#getpsichi">getpsichi</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">ugrid</tt><tt class="py-op">,</tt> <tt class="py-param">vgrid</tt><tt class="py-op">,</tt> <tt class="py-param">ntrunc</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Spharmt.getpsichi-collapsed" style="display:none;" pad="++++" indent="++++++++"></div><div id="Spharmt.getpsichi-expanded"><a name="L768"></a><tt class="py-lineno"> 768</tt>  <tt class="py-line"> </tt>
<a name="L769"></a><tt class="py-lineno"> 769</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L770"></a><tt class="py-lineno"> 770</tt>  <tt class="py-line"><tt class="py-docstring"> compute streamfunction and velocity potential on grid given vector wind.</tt> </tt>
<a name="L771"></a><tt class="py-lineno"> 771</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L772"></a><tt class="py-lineno"> 772</tt>  <tt class="py-line"><tt class="py-docstring"> @param ugrid: rank 2 or 3 numpy float32 array containing grid of zonal</tt> </tt>
<a name="L773"></a><tt class="py-lineno"> 773</tt>  <tt class="py-line"><tt class="py-docstring"> winds.  Must have shape (nlat,nlon) or (nlat,nlon,nt), where nt is the number</tt> </tt>
<a name="L774"></a><tt class="py-lineno"> 774</tt>  <tt class="py-line"><tt class="py-docstring"> of grids to be transformed.  If ugrid is rank 2, nt is assumed to be 1.</tt> </tt>
<a name="L775"></a><tt class="py-lineno"> 775</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L776"></a><tt class="py-lineno"> 776</tt>  <tt class="py-line"><tt class="py-docstring"> @param vgrid: rank 2 or 3 numpy float32 array containing grid of meridional</tt> </tt>
<a name="L777"></a><tt class="py-lineno"> 777</tt>  <tt class="py-line"><tt class="py-docstring"> winds.  Must have shape (nlat,nlon) or (nlat,nlon,nt), where nt is the number</tt> </tt>
<a name="L778"></a><tt class="py-lineno"> 778</tt>  <tt class="py-line"><tt class="py-docstring"> of grids to be transformed.  Both ugrid and vgrid must have the same shape.</tt> </tt>
<a name="L779"></a><tt class="py-lineno"> 779</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L780"></a><tt class="py-lineno"> 780</tt>  <tt class="py-line"><tt class="py-docstring"> @keyword ntrunc:  optional spectral truncation limit.</tt> </tt>
<a name="L781"></a><tt class="py-lineno"> 781</tt>  <tt class="py-line"><tt class="py-docstring"> (default self.nlat-1)</tt> </tt>
<a name="L782"></a><tt class="py-lineno"> 782</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L783"></a><tt class="py-lineno"> 783</tt>  <tt class="py-line"><tt class="py-docstring"> @return: C{B{psigrid, chigrid}} - rank 2 or 3 numpy float32 arrays</tt> </tt>
<a name="L784"></a><tt class="py-lineno"> 784</tt>  <tt class="py-line"><tt class="py-docstring"> of gridded streamfunction and velocity potential. Shapes are either</tt> </tt>
<a name="L785"></a><tt class="py-lineno"> 785</tt>  <tt class="py-line"><tt class="py-docstring"> (nlat,nlon) or (nlat,nlon,nt).</tt> </tt>
<a name="L786"></a><tt class="py-lineno"> 786</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L787"></a><tt class="py-lineno"> 787</tt>  <tt class="py-line"> </tt>
<a name="L788"></a><tt class="py-lineno"> 788</tt>  <tt class="py-line"><tt class="py-comment"># make sure ugrid,vgrid are rank 2 or 3 and same shape.</tt> </tt>
<a name="L789"></a><tt class="py-lineno"> 789</tt>  <tt class="py-line"> </tt>
<a name="L790"></a><tt class="py-lineno"> 790</tt>  <tt class="py-line">        <tt class="py-name">idim</tt> <tt class="py-op">=</tt> <tt class="py-name">ugrid</tt><tt class="py-op">.</tt><tt class="py-name">ndim</tt> </tt>
<a name="L791"></a><tt class="py-lineno"> 791</tt>  <tt class="py-line"> </tt>
<a name="L792"></a><tt class="py-lineno"> 792</tt>  <tt class="py-line">        <tt class="py-name">shapeu</tt> <tt class="py-op">=</tt> <tt class="py-name">ugrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt> </tt>
<a name="L793"></a><tt class="py-lineno"> 793</tt>  <tt class="py-line">        <tt class="py-name">shapev</tt> <tt class="py-op">=</tt> <tt class="py-name">vgrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt> </tt>
<a name="L794"></a><tt class="py-lineno"> 794</tt>  <tt class="py-line"> </tt>
<a name="L795"></a><tt class="py-lineno"> 795</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">ntrunc</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
<a name="L796"></a><tt class="py-lineno"> 796</tt>  <tt class="py-line">            <tt class="py-name">ntrunc</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt><tt class="py-op">-</tt><tt class="py-number">1</tt> </tt>
<a name="L797"></a><tt class="py-lineno"> 797</tt>  <tt class="py-line"> </tt>
<a name="L798"></a><tt class="py-lineno"> 798</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">shapeu</tt> <tt class="py-op">!=</tt> <tt class="py-name">shapev</tt><tt class="py-op">:</tt> </tt>
<a name="L799"></a><tt class="py-lineno"> 799</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'getvrtdivspec input arrays must be same shape!'</tt> </tt>
<a name="L800"></a><tt class="py-lineno"> 800</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L801"></a><tt class="py-lineno"> 801</tt>  <tt class="py-line"> </tt>
<a name="L802"></a><tt class="py-lineno"> 802</tt>  <tt class="py-line"> </tt>
<a name="L803"></a><tt class="py-lineno"> 803</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">shapeu</tt><tt class="py-op">)</tt> <tt class="py-op">!=</tt><tt class="py-number">2</tt> <tt class="py-keyword">and</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">shapeu</tt><tt class="py-op">)</tt> <tt class="py-op">!=</tt><tt class="py-number">3</tt><tt class="py-op">:</tt> </tt>
<a name="L804"></a><tt class="py-lineno"> 804</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'getvrtdivspec needs rank two or three arrays!'</tt> </tt>
<a name="L805"></a><tt class="py-lineno"> 805</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L806"></a><tt class="py-lineno"> 806</tt>  <tt class="py-line"> </tt>
<a name="L807"></a><tt class="py-lineno"> 807</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">shapeu</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt> <tt class="py-keyword">or</tt> <tt class="py-name">shapeu</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlon</tt><tt class="py-op">:</tt> </tt>
<a name="L808"></a><tt class="py-lineno"> 808</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'getpsichi needs input arrays whose first two dimensions are si%d and %d, got %d and %d'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">ugrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-name">ugrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">,</tt><tt class="py-op">)</tt> </tt>
<a name="L809"></a><tt class="py-lineno"> 809</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L810"></a><tt class="py-lineno"> 810</tt>  <tt class="py-line"> </tt>
<a name="L811"></a><tt class="py-lineno"> 811</tt>  <tt class="py-line"><tt class="py-comment"># check ntrunc.</tt> </tt>
<a name="L812"></a><tt class="py-lineno"> 812</tt>  <tt class="py-line"> </tt>
<a name="L813"></a><tt class="py-lineno"> 813</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">ntrunc</tt> <tt class="py-op">&lt;</tt> <tt class="py-number">0</tt> <tt class="py-keyword">or</tt> <tt class="py-name">ntrunc</tt><tt class="py-op">+</tt><tt class="py-number">1</tt> <tt class="py-op">&gt;</tt> <tt class="py-name">ugrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">:</tt> </tt>
<a name="L814"></a><tt class="py-lineno"> 814</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'ntrunc must be between 0 and %d'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">ugrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">,</tt><tt class="py-op">)</tt> </tt>
<a name="L815"></a><tt class="py-lineno"> 815</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L816"></a><tt class="py-lineno"> 816</tt>  <tt class="py-line"> </tt>
<a name="L817"></a><tt class="py-lineno"> 817</tt>  <tt class="py-line"><tt class="py-comment"># compute spectral coeffs of vort, div.</tt> </tt>
<a name="L818"></a><tt class="py-lineno"> 818</tt>  <tt class="py-line"> </tt>
<a name="L819"></a><tt class="py-lineno"> 819</tt>  <tt class="py-line">        <tt class="py-name">vrtspec</tt><tt class="py-op">,</tt> <tt class="py-name">divspec</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-4" class="py-name" targets="Method spharm.spharm.Spharmt.getvrtdivspec()=spharm.spharm.Spharmt-class.html#getvrtdivspec"><a title="spharm.spharm.Spharmt.getvrtdivspec" class="py-name" href="#" onclick="return doclink('link-4', 'getvrtdivspec', 'link-4');">getvrtdivspec</a></tt><tt class="py-op">(</tt><tt class="py-name">ugrid</tt><tt class="py-op">,</tt> <tt class="py-name">vgrid</tt><tt class="py-op">,</tt> <tt class="py-name">ntrunc</tt><tt class="py-op">)</tt> </tt>
<a name="L820"></a><tt class="py-lineno"> 820</tt>  <tt class="py-line"> </tt>
<a name="L821"></a><tt class="py-lineno"> 821</tt>  <tt class="py-line"><tt class="py-comment"># number of grids to compute.</tt> </tt>
<a name="L822"></a><tt class="py-lineno"> 822</tt>  <tt class="py-line"> </tt>
<a name="L823"></a><tt class="py-lineno"> 823</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">vrtspec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt> <tt class="py-op">==</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
<a name="L824"></a><tt class="py-lineno"> 824</tt>  <tt class="py-line">            <tt class="py-name">nt</tt> <tt class="py-op">=</tt> <tt class="py-number">1</tt> </tt>
<a name="L825"></a><tt class="py-lineno"> 825</tt>  <tt class="py-line">            <tt class="py-name">vrtspec</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">reshape</tt><tt class="py-op">(</tt><tt class="py-name">vrtspec</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-op">(</tt><tt class="py-name">ntrunc</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">ntrunc</tt><tt class="py-op">+</tt><tt class="py-number">2</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt><tt class="py-op">,</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L826"></a><tt class="py-lineno"> 826</tt>  <tt class="py-line">            <tt class="py-name">divspec</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">reshape</tt><tt class="py-op">(</tt><tt class="py-name">divspec</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-op">(</tt><tt class="py-name">ntrunc</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">ntrunc</tt><tt class="py-op">+</tt><tt class="py-number">2</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt><tt class="py-op">,</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L827"></a><tt class="py-lineno"> 827</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L828"></a><tt class="py-lineno"> 828</tt>  <tt class="py-line">            <tt class="py-name">nt</tt> <tt class="py-op">=</tt> <tt class="py-name">vrtspec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
<a name="L829"></a><tt class="py-lineno"> 829</tt>  <tt class="py-line"> </tt>
<a name="L830"></a><tt class="py-lineno"> 830</tt>  <tt class="py-line"><tt class="py-comment"># convert to spectral coeffs of psi, chi.</tt> </tt>
<a name="L831"></a><tt class="py-lineno"> 831</tt>  <tt class="py-line"> </tt>
<a name="L832"></a><tt class="py-lineno"> 832</tt>  <tt class="py-line">        <tt class="py-name">psispec</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">invlap</tt><tt class="py-op">(</tt><tt class="py-name">vrtspec</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">rsphere</tt><tt class="py-op">)</tt> </tt>
<a name="L833"></a><tt class="py-lineno"> 833</tt>  <tt class="py-line">        <tt class="py-name">chispec</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">invlap</tt><tt class="py-op">(</tt><tt class="py-name">divspec</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">rsphere</tt><tt class="py-op">)</tt> </tt>
<a name="L834"></a><tt class="py-lineno"> 834</tt>  <tt class="py-line"> </tt>
<a name="L835"></a><tt class="py-lineno"> 835</tt>  <tt class="py-line"><tt class="py-comment"># inverse transform to grid.</tt> </tt>
<a name="L836"></a><tt class="py-lineno"> 836</tt>  <tt class="py-line"> </tt>
<a name="L837"></a><tt class="py-lineno"> 837</tt>  <tt class="py-line">        <tt class="py-name">psigrid</tt> <tt class="py-op">=</tt>  <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-5" class="py-name" targets="Method spharm.spharm.Spharmt.spectogrd()=spharm.spharm.Spharmt-class.html#spectogrd"><a title="spharm.spharm.Spharmt.spectogrd" class="py-name" href="#" onclick="return doclink('link-5', 'spectogrd', 'link-5');">spectogrd</a></tt><tt class="py-op">(</tt><tt class="py-name">psispec</tt><tt class="py-op">)</tt> </tt>
<a name="L838"></a><tt class="py-lineno"> 838</tt>  <tt class="py-line">        <tt class="py-name">chigrid</tt> <tt class="py-op">=</tt>  <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-6" class="py-name"><a title="spharm.spharm.Spharmt.spectogrd" class="py-name" href="#" onclick="return doclink('link-6', 'spectogrd', 'link-5');">spectogrd</a></tt><tt class="py-op">(</tt><tt class="py-name">chispec</tt><tt class="py-op">)</tt> </tt>
<a name="L839"></a><tt class="py-lineno"> 839</tt>  <tt class="py-line"> </tt>
<a name="L840"></a><tt class="py-lineno"> 840</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">idim</tt> <tt class="py-op">==</tt> <tt class="py-number">2</tt><tt class="py-op">:</tt> </tt>
<a name="L841"></a><tt class="py-lineno"> 841</tt>  <tt class="py-line">            <tt class="py-keyword">return</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">squeeze</tt><tt class="py-op">(</tt><tt class="py-name">psigrid</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">squeeze</tt><tt class="py-op">(</tt><tt class="py-name">chigrid</tt><tt class="py-op">)</tt> </tt>
<a name="L842"></a><tt class="py-lineno"> 842</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L843"></a><tt class="py-lineno"> 843</tt>  <tt class="py-line">            <tt class="py-keyword">return</tt> <tt class="py-name">psigrid</tt><tt class="py-op">,</tt> <tt class="py-name">chigrid</tt> </tt>
</div><a name="L844"></a><tt class="py-lineno"> 844</tt>  <tt class="py-line"> </tt>
<a name="Spharmt.getgrad"></a><div id="Spharmt.getgrad-def"><a name="L845"></a><tt class="py-lineno"> 845</tt> <a class="py-toggle" href="#" id="Spharmt.getgrad-toggle" onclick="return toggle('Spharmt.getgrad');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="spharm.spharm.Spharmt-class.html#getgrad">getgrad</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">chispec</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Spharmt.getgrad-collapsed" style="display:none;" pad="++++" indent="++++++++"></div><div id="Spharmt.getgrad-expanded"><a name="L846"></a><tt class="py-lineno"> 846</tt>  <tt class="py-line"> </tt>
<a name="L847"></a><tt class="py-lineno"> 847</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L848"></a><tt class="py-lineno"> 848</tt>  <tt class="py-line"><tt class="py-docstring"> compute vector gradient on grid given complex spectral coefficients.</tt> </tt>
<a name="L849"></a><tt class="py-lineno"> 849</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L850"></a><tt class="py-lineno"> 850</tt>  <tt class="py-line"><tt class="py-docstring"> @param chispec: rank 1 or 2 numpy complex array with shape</tt> </tt>
<a name="L851"></a><tt class="py-lineno"> 851</tt>  <tt class="py-line"><tt class="py-docstring"> (ntrunc+1)*(ntrunc+2)/2 or ((ntrunc+1)*(ntrunc+2)/2,nt) containing</tt> </tt>
<a name="L852"></a><tt class="py-lineno"> 852</tt>  <tt class="py-line"><tt class="py-docstring"> complex spherical harmonic coefficients (where ntrunc is the</tt> </tt>
<a name="L853"></a><tt class="py-lineno"> 853</tt>  <tt class="py-line"><tt class="py-docstring"> triangular truncation limit and nt is the number of spectral arrays</tt> </tt>
<a name="L854"></a><tt class="py-lineno"> 854</tt>  <tt class="py-line"><tt class="py-docstring"> to be transformed). If chispec is rank 1, nt is assumed to be 1.</tt> </tt>
<a name="L855"></a><tt class="py-lineno"> 855</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L856"></a><tt class="py-lineno"> 856</tt>  <tt class="py-line"><tt class="py-docstring"> @return: C{B{uchi, vchi}} - rank 2 or 3 numpy float32 arrays containing</tt> </tt>
<a name="L857"></a><tt class="py-lineno"> 857</tt>  <tt class="py-line"><tt class="py-docstring"> gridded zonal and meridional components of the vector gradient.</tt> </tt>
<a name="L858"></a><tt class="py-lineno"> 858</tt>  <tt class="py-line"><tt class="py-docstring"> Shapes are either (nlat,nlon) or (nlat,nlon,nt).</tt> </tt>
<a name="L859"></a><tt class="py-lineno"> 859</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L860"></a><tt class="py-lineno"> 860</tt>  <tt class="py-line"> </tt>
<a name="L861"></a><tt class="py-lineno"> 861</tt>  <tt class="py-line"><tt class="py-comment"># make sure chispec is rank 1 or 2.</tt> </tt>
<a name="L862"></a><tt class="py-lineno"> 862</tt>  <tt class="py-line"> </tt>
<a name="L863"></a><tt class="py-lineno"> 863</tt>  <tt class="py-line">        <tt class="py-name">idim</tt> <tt class="py-op">=</tt> <tt class="py-name">chispec</tt><tt class="py-op">.</tt><tt class="py-name">ndim</tt> </tt>
<a name="L864"></a><tt class="py-lineno"> 864</tt>  <tt class="py-line"> </tt>
<a name="L865"></a><tt class="py-lineno"> 865</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">chispec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt> <tt class="py-op">!=</tt><tt class="py-number">1</tt> <tt class="py-keyword">and</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">chispec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt> <tt class="py-op">!=</tt><tt class="py-number">2</tt><tt class="py-op">:</tt> </tt>
<a name="L866"></a><tt class="py-lineno"> 866</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'getgrad needs rank one or two arrays!'</tt> </tt>
<a name="L867"></a><tt class="py-lineno"> 867</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L868"></a><tt class="py-lineno"> 868</tt>  <tt class="py-line"> </tt>
<a name="L869"></a><tt class="py-lineno"> 869</tt>  <tt class="py-line"><tt class="py-comment"># infer ntrunc from size of chispec (chispec must be rank 1!)</tt> </tt>
<a name="L870"></a><tt class="py-lineno"> 870</tt>  <tt class="py-line"><tt class="py-comment"># chispec is assumed to have size (ntrunc+1)*(ntrunc+2)/2</tt> </tt>
<a name="L871"></a><tt class="py-lineno"> 871</tt>  <tt class="py-line"> </tt>
<a name="L872"></a><tt class="py-lineno"> 872</tt>  <tt class="py-line">        <tt class="py-name">ntrunc</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-op">-</tt><tt class="py-number">1.5</tt> <tt class="py-op">+</tt> <tt class="py-number">0.5</tt><tt class="py-op">*</tt><tt class="py-name">math</tt><tt class="py-op">.</tt><tt class="py-name">sqrt</tt><tt class="py-op">(</tt><tt class="py-number">9.</tt><tt class="py-op">-</tt><tt class="py-number">8.</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-number">1.</tt><tt class="py-op">-</tt><tt class="py-name">chispec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L873"></a><tt class="py-lineno"> 873</tt>  <tt class="py-line"> </tt>
<a name="L874"></a><tt class="py-lineno"> 874</tt>  <tt class="py-line"><tt class="py-comment"># number of grids to compute.</tt> </tt>
<a name="L875"></a><tt class="py-lineno"> 875</tt>  <tt class="py-line"> </tt>
<a name="L876"></a><tt class="py-lineno"> 876</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">chispec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt> <tt class="py-op">==</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
<a name="L877"></a><tt class="py-lineno"> 877</tt>  <tt class="py-line">            <tt class="py-name">nt</tt> <tt class="py-op">=</tt> <tt class="py-number">1</tt> </tt>
<a name="L878"></a><tt class="py-lineno"> 878</tt>  <tt class="py-line">            <tt class="py-name">chispec</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">reshape</tt><tt class="py-op">(</tt><tt class="py-name">chispec</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-op">(</tt><tt class="py-name">ntrunc</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">ntrunc</tt><tt class="py-op">+</tt><tt class="py-number">2</tt><tt class="py-op">)</tt><tt class="py-op">/</tt><tt class="py-number">2</tt><tt class="py-op">,</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L879"></a><tt class="py-lineno"> 879</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L880"></a><tt class="py-lineno"> 880</tt>  <tt class="py-line">            <tt class="py-name">nt</tt> <tt class="py-op">=</tt> <tt class="py-name">chispec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
<a name="L881"></a><tt class="py-lineno"> 881</tt>  <tt class="py-line"> </tt>
<a name="L882"></a><tt class="py-lineno"> 882</tt>  <tt class="py-line"><tt class="py-comment"># convert chispec to divspec.</tt> </tt>
<a name="L883"></a><tt class="py-lineno"> 883</tt>  <tt class="py-line"> </tt>
<a name="L884"></a><tt class="py-lineno"> 884</tt>  <tt class="py-line">        <tt class="py-name">divspec</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">lap</tt><tt class="py-op">(</tt><tt class="py-name">chispec</tt><tt class="py-op">,</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">rsphere</tt><tt class="py-op">)</tt> </tt>
<a name="L885"></a><tt class="py-lineno"> 885</tt>  <tt class="py-line"> </tt>
<a name="L886"></a><tt class="py-lineno"> 886</tt>  <tt class="py-line"><tt class="py-comment"># call getuv, with vrtspec=0, to get uchi,vchi.</tt> </tt>
<a name="L887"></a><tt class="py-lineno"> 887</tt>  <tt class="py-line"> </tt>
<a name="L888"></a><tt class="py-lineno"> 888</tt>  <tt class="py-line">        <tt class="py-name">uchi</tt><tt class="py-op">,</tt> <tt class="py-name">vchi</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-7" class="py-name" targets="Method spharm.spharm.Spharmt.getuv()=spharm.spharm.Spharmt-class.html#getuv"><a title="spharm.spharm.Spharmt.getuv" class="py-name" href="#" onclick="return doclink('link-7', 'getuv', 'link-7');">getuv</a></tt><tt class="py-op">(</tt><tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">zeros</tt><tt class="py-op">(</tt><tt class="py-name">chispec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">,</tt> <tt class="py-name">chispec</tt><tt class="py-op">.</tt><tt class="py-name">dtype</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt class="py-name">divspec</tt><tt class="py-op">)</tt> </tt>
<a name="L889"></a><tt class="py-lineno"> 889</tt>  <tt class="py-line"> </tt>
<a name="L890"></a><tt class="py-lineno"> 890</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">idim</tt> <tt class="py-op">==</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
<a name="L891"></a><tt class="py-lineno"> 891</tt>  <tt class="py-line">            <tt class="py-keyword">return</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">squeeze</tt><tt class="py-op">(</tt><tt class="py-name">uchi</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">squeeze</tt><tt class="py-op">(</tt><tt class="py-name">vchi</tt><tt class="py-op">)</tt> </tt>
<a name="L892"></a><tt class="py-lineno"> 892</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L893"></a><tt class="py-lineno"> 893</tt>  <tt class="py-line">            <tt class="py-keyword">return</tt> <tt class="py-name">uchi</tt><tt class="py-op">,</tt> <tt class="py-name">vchi</tt> </tt>
</div><a name="L894"></a><tt class="py-lineno"> 894</tt>  <tt class="py-line"> </tt>
<a name="Spharmt.specsmooth"></a><div id="Spharmt.specsmooth-def"><a name="L895"></a><tt class="py-lineno"> 895</tt> <a class="py-toggle" href="#" id="Spharmt.specsmooth-toggle" onclick="return toggle('Spharmt.specsmooth');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="spharm.spharm.Spharmt-class.html#specsmooth">specsmooth</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">datagrid</tt><tt class="py-op">,</tt> <tt class="py-param">smooth</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="Spharmt.specsmooth-collapsed" style="display:none;" pad="++++" indent="++++++++"></div><div id="Spharmt.specsmooth-expanded"><a name="L896"></a><tt class="py-lineno"> 896</tt>  <tt class="py-line"> </tt>
<a name="L897"></a><tt class="py-lineno"> 897</tt>  <tt class="py-line">        <tt class="py-docstring">"""</tt> </tt>
<a name="L898"></a><tt class="py-lineno"> 898</tt>  <tt class="py-line"><tt class="py-docstring"> isotropic spectral smoothing on a sphere.</tt> </tt>
<a name="L899"></a><tt class="py-lineno"> 899</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L900"></a><tt class="py-lineno"> 900</tt>  <tt class="py-line"><tt class="py-docstring"> @param datagrid: rank 2 or 3 numpy float32 array with shape (nlat,nlon) or</tt> </tt>
<a name="L901"></a><tt class="py-lineno"> 901</tt>  <tt class="py-line"><tt class="py-docstring"> (nlat,nlon,nt), where nt is the number of grids to be smoothed.  If</tt> </tt>
<a name="L902"></a><tt class="py-lineno"> 902</tt>  <tt class="py-line"><tt class="py-docstring"> datagrid is rank 2, nt is assumed to be 1.</tt> </tt>
<a name="L903"></a><tt class="py-lineno"> 903</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L904"></a><tt class="py-lineno"> 904</tt>  <tt class="py-line"><tt class="py-docstring"> @param smooth: rank 1 array of length nlat containing smoothing factors</tt> </tt>
<a name="L905"></a><tt class="py-lineno"> 905</tt>  <tt class="py-line"><tt class="py-docstring"> as a function of total wavenumber.</tt> </tt>
<a name="L906"></a><tt class="py-lineno"> 906</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L907"></a><tt class="py-lineno"> 907</tt>  <tt class="py-line"><tt class="py-docstring"> @return: C{B{datagrid}} - rank 2 or 3 numpy float32 array with shape</tt> </tt>
<a name="L908"></a><tt class="py-lineno"> 908</tt>  <tt class="py-line"><tt class="py-docstring"> (nlat,nlon) or (nlat,nlon,nt) containing the smoothed grids.</tt> </tt>
<a name="L909"></a><tt class="py-lineno"> 909</tt>  <tt class="py-line"><tt class="py-docstring">        """</tt> </tt>
<a name="L910"></a><tt class="py-lineno"> 910</tt>  <tt class="py-line"> </tt>
<a name="L911"></a><tt class="py-lineno"> 911</tt>  <tt class="py-line"><tt class="py-comment"># check that datagrid is rank 2 or 3 with size (self.nlat, self.nlon) or</tt> </tt>
<a name="L912"></a><tt class="py-lineno"> 912</tt>  <tt class="py-line"><tt class="py-comment"># (self.nlat, self.nlon, nt) where nt is number of grids to transform.</tt> </tt>
<a name="L913"></a><tt class="py-lineno"> 913</tt>  <tt class="py-line"> </tt>
<a name="L914"></a><tt class="py-lineno"> 914</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt> <tt class="py-op">&gt;</tt> <tt class="py-number">3</tt><tt class="py-op">:</tt> </tt>
<a name="L915"></a><tt class="py-lineno"> 915</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'specsmooth needs a rank two or three array, got %d'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt><tt class="py-op">,</tt><tt class="py-op">)</tt> </tt>
<a name="L916"></a><tt class="py-lineno"> 916</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L917"></a><tt class="py-lineno"> 917</tt>  <tt class="py-line"> </tt>
<a name="L918"></a><tt class="py-lineno"> 918</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt> <tt class="py-keyword">or</tt> <tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlon</tt><tt class="py-op">:</tt> </tt>
<a name="L919"></a><tt class="py-lineno"> 919</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'specsmooth needs an array of size %d by %d, got %d by %d'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">,</tt><tt class="py-op">)</tt> </tt>
<a name="L920"></a><tt class="py-lineno"> 920</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L921"></a><tt class="py-lineno"> 921</tt>  <tt class="py-line"> </tt>
<a name="L922"></a><tt class="py-lineno"> 922</tt>  <tt class="py-line"> </tt>
<a name="L923"></a><tt class="py-lineno"> 923</tt>  <tt class="py-line"><tt class="py-comment"># make sure smooth is rank 1, same size as datagrid.shape[0]</tt> </tt>
<a name="L924"></a><tt class="py-lineno"> 924</tt>  <tt class="py-line"> </tt>
<a name="L925"></a><tt class="py-lineno"> 925</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">smooth</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt> <tt class="py-op">!=</tt><tt class="py-number">1</tt> <tt class="py-keyword">or</tt> <tt class="py-name">smooth</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">:</tt> </tt>
<a name="L926"></a><tt class="py-lineno"> 926</tt>  <tt class="py-line">            <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'smooth must be rank 1 and same size as datagrid.shape[0] in specsmooth!'</tt> </tt>
<a name="L927"></a><tt class="py-lineno"> 927</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L928"></a><tt class="py-lineno"> 928</tt>  <tt class="py-line"> </tt>
<a name="L929"></a><tt class="py-lineno"> 929</tt>  <tt class="py-line"><tt class="py-comment"># grid to spectral transform.</tt> </tt>
<a name="L930"></a><tt class="py-lineno"> 930</tt>  <tt class="py-line"> </tt>
<a name="L931"></a><tt class="py-lineno"> 931</tt>  <tt class="py-line">        <tt class="py-name">nlat</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt> </tt>
<a name="L932"></a><tt class="py-lineno"> 932</tt>  <tt class="py-line">        <tt class="py-name">dataspec</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-8" class="py-name" targets="Method spharm.spharm.Spharmt.grdtospec()=spharm.spharm.Spharmt-class.html#grdtospec"><a title="spharm.spharm.Spharmt.grdtospec" class="py-name" href="#" onclick="return doclink('link-8', 'grdtospec', 'link-8');">grdtospec</a></tt><tt class="py-op">(</tt><tt class="py-name">datagrid</tt><tt class="py-op">,</tt> <tt class="py-name">nlat</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">)</tt> </tt>
<a name="L933"></a><tt class="py-lineno"> 933</tt>  <tt class="py-line"> </tt>
<a name="L934"></a><tt class="py-lineno"> 934</tt>  <tt class="py-line"><tt class="py-comment"># multiply spectral coeffs. by smoothing factor.</tt> </tt>
<a name="L935"></a><tt class="py-lineno"> 935</tt>  <tt class="py-line"> </tt>
<a name="L936"></a><tt class="py-lineno"> 936</tt>  <tt class="py-line">        <tt class="py-name">dataspec</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">multsmoothfact</tt><tt class="py-op">(</tt><tt class="py-name">dataspec</tt><tt class="py-op">,</tt> <tt class="py-name">smooth</tt><tt class="py-op">)</tt> </tt>
<a name="L937"></a><tt class="py-lineno"> 937</tt>  <tt class="py-line"> </tt>
<a name="L938"></a><tt class="py-lineno"> 938</tt>  <tt class="py-line"><tt class="py-comment"># spectral to grid transform.</tt> </tt>
<a name="L939"></a><tt class="py-lineno"> 939</tt>  <tt class="py-line"> </tt>
<a name="L940"></a><tt class="py-lineno"> 940</tt>  <tt class="py-line">        <tt class="py-name">datagrid</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-9" class="py-name"><a title="spharm.spharm.Spharmt.spectogrd" class="py-name" href="#" onclick="return doclink('link-9', 'spectogrd', 'link-5');">spectogrd</a></tt><tt class="py-op">(</tt><tt class="py-name">dataspec</tt><tt class="py-op">)</tt> </tt>
<a name="L941"></a><tt class="py-lineno"> 941</tt>  <tt class="py-line"> </tt>
<a name="L942"></a><tt class="py-lineno"> 942</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">datagrid</tt> </tt>
</div></div><a name="L943"></a><tt class="py-lineno"> 943</tt>  <tt class="py-line"> </tt>
<a name="regrid"></a><div id="regrid-def"><a name="L944"></a><tt class="py-lineno"> 944</tt> <a class="py-toggle" href="#" id="regrid-toggle" onclick="return toggle('regrid');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="spharm.spharm-module.html#regrid">regrid</a><tt class="py-op">(</tt><tt class="py-param">grdin</tt><tt class="py-op">,</tt> <tt class="py-param">grdout</tt><tt class="py-op">,</tt> <tt class="py-param">datagrid</tt><tt class="py-op">,</tt> <tt class="py-param">ntrunc</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">,</tt> <tt class="py-param">smooth</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="regrid-collapsed" style="display:none;" pad="++++" indent="++++"></div><div id="regrid-expanded"><a name="L945"></a><tt class="py-lineno"> 945</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L946"></a><tt class="py-lineno"> 946</tt>  <tt class="py-line"><tt class="py-docstring"> regrid data using spectral interpolation, while performing</tt> </tt>
<a name="L947"></a><tt class="py-lineno"> 947</tt>  <tt class="py-line"><tt class="py-docstring"> optional spectral smoothing and/or truncation.</tt> </tt>
<a name="L948"></a><tt class="py-lineno"> 948</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L949"></a><tt class="py-lineno"> 949</tt>  <tt class="py-line"><tt class="py-docstring"> @param grdin: Spharmt class instance describing input grid.</tt> </tt>
<a name="L950"></a><tt class="py-lineno"> 950</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L951"></a><tt class="py-lineno"> 951</tt>  <tt class="py-line"><tt class="py-docstring"> @param grdout: Spharmt class instance describing output grid.</tt> </tt>
<a name="L952"></a><tt class="py-lineno"> 952</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L953"></a><tt class="py-lineno"> 953</tt>  <tt class="py-line"><tt class="py-docstring"> @param datagrid: data on input grid (grdin.nlat x grdin.nlon). If</tt> </tt>
<a name="L954"></a><tt class="py-lineno"> 954</tt>  <tt class="py-line"><tt class="py-docstring"> datagrid is rank 3, last dimension is the number of grids to interpolate.</tt> </tt>
<a name="L955"></a><tt class="py-lineno"> 955</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L956"></a><tt class="py-lineno"> 956</tt>  <tt class="py-line"><tt class="py-docstring"> @keyword ntrunc:  optional spectral truncation limit for datagrid</tt> </tt>
<a name="L957"></a><tt class="py-lineno"> 957</tt>  <tt class="py-line"><tt class="py-docstring"> (default min(grdin.nlat-1,grdout.nlat-1)).</tt> </tt>
<a name="L958"></a><tt class="py-lineno"> 958</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L959"></a><tt class="py-lineno"> 959</tt>  <tt class="py-line"><tt class="py-docstring"> @keyword smooth: rank 1 array of length grdout.nlat containing smoothing</tt> </tt>
<a name="L960"></a><tt class="py-lineno"> 960</tt>  <tt class="py-line"><tt class="py-docstring"> factors as a function of total wavenumber (default is no smoothing).</tt> </tt>
<a name="L961"></a><tt class="py-lineno"> 961</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L962"></a><tt class="py-lineno"> 962</tt>  <tt class="py-line"><tt class="py-docstring"> @return: C{B{datagrid}} - interpolated (and optionally smoothed) array(s)</tt> </tt>
<a name="L963"></a><tt class="py-lineno"> 963</tt>  <tt class="py-line"><tt class="py-docstring"> on grdout.nlon x grdout.nlat grid.</tt> </tt>
<a name="L964"></a><tt class="py-lineno"> 964</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L965"></a><tt class="py-lineno"> 965</tt>  <tt class="py-line"> </tt>
<a name="L966"></a><tt class="py-lineno"> 966</tt>  <tt class="py-line"><tt class="py-comment"># check that datagrid is rank 2 or 3 with size (grdin.nlat, grdin.nlon) or</tt> </tt>
<a name="L967"></a><tt class="py-lineno"> 967</tt>  <tt class="py-line"><tt class="py-comment"># (grdin.nlat, grdin.nlon, nt) where nt is number of grids to transform.</tt> </tt>
<a name="L968"></a><tt class="py-lineno"> 968</tt>  <tt class="py-line"> </tt>
<a name="L969"></a><tt class="py-lineno"> 969</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt> <tt class="py-op">&gt;</tt> <tt class="py-number">3</tt><tt class="py-op">:</tt> </tt>
<a name="L970"></a><tt class="py-lineno"> 970</tt>  <tt class="py-line">        <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'regrid needs a rank two or three array, got %d'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt><tt class="py-op">,</tt><tt class="py-op">)</tt> </tt>
<a name="L971"></a><tt class="py-lineno"> 971</tt>  <tt class="py-line">        <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L972"></a><tt class="py-lineno"> 972</tt>  <tt class="py-line"> </tt>
<a name="L973"></a><tt class="py-lineno"> 973</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt class="py-name">grdin</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt> <tt class="py-keyword">or</tt> <tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt class="py-name">grdin</tt><tt class="py-op">.</tt><tt class="py-name">nlon</tt><tt class="py-op">:</tt> </tt>
<a name="L974"></a><tt class="py-lineno"> 974</tt>  <tt class="py-line">        <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'grdtospec needs an array of size %d by %d, got %d by %d'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">grdin</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt><tt class="py-op">,</tt> <tt class="py-name">grdin</tt><tt class="py-op">.</tt><tt class="py-name">nlon</tt><tt class="py-op">,</tt> <tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-name">datagrid</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">,</tt><tt class="py-op">)</tt> </tt>
<a name="L975"></a><tt class="py-lineno"> 975</tt>  <tt class="py-line">        <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L976"></a><tt class="py-lineno"> 976</tt>  <tt class="py-line"> </tt>
<a name="L977"></a><tt class="py-lineno"> 977</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">smooth</tt> <tt class="py-keyword">is</tt> <tt class="py-keyword">not</tt> <tt class="py-name">None</tt> <tt class="py-keyword">and</tt> <tt class="py-op">(</tt><tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">smooth</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">)</tt> <tt class="py-op">!=</tt><tt class="py-number">1</tt> <tt class="py-keyword">or</tt> <tt class="py-name">smooth</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> <tt class="py-op">!=</tt> <tt class="py-name">grdout</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L978"></a><tt class="py-lineno"> 978</tt>  <tt class="py-line">        <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'smooth must be rank 1 size grdout.nlat in regrid!'</tt> </tt>
<a name="L979"></a><tt class="py-lineno"> 979</tt>  <tt class="py-line">        <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L980"></a><tt class="py-lineno"> 980</tt>  <tt class="py-line"> </tt>
<a name="L981"></a><tt class="py-lineno"> 981</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">ntrunc</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
<a name="L982"></a><tt class="py-lineno"> 982</tt>  <tt class="py-line">        <tt class="py-name">ntrunc</tt> <tt class="py-op">=</tt> <tt class="py-name">min</tt><tt class="py-op">(</tt><tt class="py-name">grdout</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">,</tt><tt class="py-name">grdin</tt><tt class="py-op">.</tt><tt class="py-name">nlat</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">)</tt> </tt>
<a name="L983"></a><tt class="py-lineno"> 983</tt>  <tt class="py-line"> </tt>
<a name="L984"></a><tt class="py-lineno"> 984</tt>  <tt class="py-line">    <tt class="py-name">dataspec</tt> <tt class="py-op">=</tt> <tt class="py-name">grdin</tt><tt class="py-op">.</tt><tt id="link-10" class="py-name"><a title="spharm.spharm.Spharmt.grdtospec" class="py-name" href="#" onclick="return doclink('link-10', 'grdtospec', 'link-8');">grdtospec</a></tt><tt class="py-op">(</tt><tt class="py-name">datagrid</tt><tt class="py-op">,</tt><tt class="py-name">ntrunc</tt><tt class="py-op">)</tt> </tt>
<a name="L985"></a><tt class="py-lineno"> 985</tt>  <tt class="py-line"> </tt>
<a name="L986"></a><tt class="py-lineno"> 986</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">smooth</tt> <tt class="py-keyword">is</tt> <tt class="py-keyword">not</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
<a name="L987"></a><tt class="py-lineno"> 987</tt>  <tt class="py-line">        <tt class="py-name">dataspec</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">multsmoothfact</tt><tt class="py-op">(</tt><tt class="py-name">dataspec</tt><tt class="py-op">,</tt> <tt class="py-name">smooth</tt><tt class="py-op">)</tt> </tt>
<a name="L988"></a><tt class="py-lineno"> 988</tt>  <tt class="py-line"> </tt>
<a name="L989"></a><tt class="py-lineno"> 989</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">grdout</tt><tt class="py-op">.</tt><tt id="link-11" class="py-name"><a title="spharm.spharm.Spharmt.spectogrd" class="py-name" href="#" onclick="return doclink('link-11', 'spectogrd', 'link-5');">spectogrd</a></tt><tt class="py-op">(</tt><tt class="py-name">dataspec</tt><tt class="py-op">)</tt> </tt>
</div><a name="L990"></a><tt class="py-lineno"> 990</tt>  <tt class="py-line"> </tt>
<a name="gaussian_lats_wts"></a><div id="gaussian_lats_wts-def"><a name="L991"></a><tt class="py-lineno"> 991</tt> <a class="py-toggle" href="#" id="gaussian_lats_wts-toggle" onclick="return toggle('gaussian_lats_wts');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="spharm.spharm-module.html#gaussian_lats_wts">gaussian_lats_wts</a><tt class="py-op">(</tt><tt class="py-param">nlat</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="gaussian_lats_wts-collapsed" style="display:none;" pad="++++" indent="++++"></div><div id="gaussian_lats_wts-expanded"><a name="L992"></a><tt class="py-lineno"> 992</tt>  <tt class="py-line"> </tt>
<a name="L993"></a><tt class="py-lineno"> 993</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L994"></a><tt class="py-lineno"> 994</tt>  <tt class="py-line"><tt class="py-docstring"> compute the gaussian latitudes (in degrees) and quadrature weights.</tt> </tt>
<a name="L995"></a><tt class="py-lineno"> 995</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L996"></a><tt class="py-lineno"> 996</tt>  <tt class="py-line"><tt class="py-docstring"> @param nlat: number of gaussian latitudes desired.</tt> </tt>
<a name="L997"></a><tt class="py-lineno"> 997</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L998"></a><tt class="py-lineno"> 998</tt>  <tt class="py-line"><tt class="py-docstring"> @return: C{B{lats, wts}} - rank 1 numpy float64 arrays containing</tt> </tt>
<a name="L999"></a><tt class="py-lineno"> 999</tt>  <tt class="py-line"><tt class="py-docstring"> gaussian latitudes (in degrees north) and gaussian quadrature weights.</tt> </tt>
<a name="L1000"></a><tt class="py-lineno">1000</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L1001"></a><tt class="py-lineno">1001</tt>  <tt class="py-line"> </tt>
<a name="L1002"></a><tt class="py-lineno">1002</tt>  <tt class="py-line"><tt class="py-comment"># get the gaussian colatitudes and weights using gaqd.</tt> </tt>
<a name="L1003"></a><tt class="py-lineno">1003</tt>  <tt class="py-line"> </tt>
<a name="L1004"></a><tt class="py-lineno">1004</tt>  <tt class="py-line">    <tt class="py-name">colats</tt><tt class="py-op">,</tt> <tt class="py-name">wts</tt><tt class="py-op">,</tt> <tt class="py-name">ierror</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">gaqd</tt><tt class="py-op">(</tt><tt class="py-name">nlat</tt><tt class="py-op">)</tt> </tt>
<a name="L1005"></a><tt class="py-lineno">1005</tt>  <tt class="py-line"> </tt>
<a name="L1006"></a><tt class="py-lineno">1006</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">ierror</tt> <tt class="py-op">!=</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L1007"></a><tt class="py-lineno">1007</tt>  <tt class="py-line">        <tt class="py-name">msg</tt> <tt class="py-op">=</tt> <tt class="py-string">'In return from call to gaqd ierror =  %d'</tt> <tt class="py-op">%</tt> <tt class="py-name">ierror</tt> </tt>
<a name="L1008"></a><tt class="py-lineno">1008</tt>  <tt class="py-line">        <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-name">msg</tt><tt class="py-op">)</tt> </tt>
<a name="L1009"></a><tt class="py-lineno">1009</tt>  <tt class="py-line"> </tt>
<a name="L1010"></a><tt class="py-lineno">1010</tt>  <tt class="py-line"><tt class="py-comment"># convert to degrees north latitude.</tt> </tt>
<a name="L1011"></a><tt class="py-lineno">1011</tt>  <tt class="py-line"> </tt>
<a name="L1012"></a><tt class="py-lineno">1012</tt>  <tt class="py-line">    <tt class="py-name">lats</tt> <tt class="py-op">=</tt> <tt class="py-number">90.0</tt> <tt class="py-op">-</tt> <tt class="py-name">colats</tt><tt class="py-op">*</tt><tt class="py-number">180.0</tt><tt class="py-op">/</tt><tt class="py-name">math</tt><tt class="py-op">.</tt><tt class="py-name">pi</tt> </tt>
<a name="L1013"></a><tt class="py-lineno">1013</tt>  <tt class="py-line"> </tt>
<a name="L1014"></a><tt class="py-lineno">1014</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">lats</tt><tt class="py-op">,</tt> <tt class="py-name">wts</tt> </tt>
</div><a name="L1015"></a><tt class="py-lineno">1015</tt>  <tt class="py-line"> </tt>
<a name="getspecindx"></a><div id="getspecindx-def"><a name="L1016"></a><tt class="py-lineno">1016</tt> <a class="py-toggle" href="#" id="getspecindx-toggle" onclick="return toggle('getspecindx');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="spharm.spharm-module.html#getspecindx">getspecindx</a><tt class="py-op">(</tt><tt class="py-param">ntrunc</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="getspecindx-collapsed" style="display:none;" pad="++++" indent="++++"></div><div id="getspecindx-expanded"><a name="L1017"></a><tt class="py-lineno">1017</tt>  <tt class="py-line"> </tt>
<a name="L1018"></a><tt class="py-lineno">1018</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L1019"></a><tt class="py-lineno">1019</tt>  <tt class="py-line"><tt class="py-docstring"> compute indices of zonal wavenumber (indxm) and degree (indxn)</tt> </tt>
<a name="L1020"></a><tt class="py-lineno">1020</tt>  <tt class="py-line"><tt class="py-docstring"> for complex spherical harmonic coefficients.</tt> </tt>
<a name="L1021"></a><tt class="py-lineno">1021</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L1022"></a><tt class="py-lineno">1022</tt>  <tt class="py-line"><tt class="py-docstring"> @param ntrunc: spherical harmonic triangular truncation limit.</tt> </tt>
<a name="L1023"></a><tt class="py-lineno">1023</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L1024"></a><tt class="py-lineno">1024</tt>  <tt class="py-line"><tt class="py-docstring"> @return: C{B{indxm, indxn}} - rank 1 numpy Int32 arrays</tt> </tt>
<a name="L1025"></a><tt class="py-lineno">1025</tt>  <tt class="py-line"><tt class="py-docstring"> containing zonal wavenumber (indxm) and degree (indxn) of</tt> </tt>
<a name="L1026"></a><tt class="py-lineno">1026</tt>  <tt class="py-line"><tt class="py-docstring"> spherical harmonic coefficients.</tt> </tt>
<a name="L1027"></a><tt class="py-lineno">1027</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L1028"></a><tt class="py-lineno">1028</tt>  <tt class="py-line"> </tt>
<a name="L1029"></a><tt class="py-lineno">1029</tt>  <tt class="py-line">    <tt class="py-name">indexn</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">indices</tt><tt class="py-op">(</tt><tt class="py-op">(</tt><tt class="py-name">ntrunc</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">,</tt><tt class="py-name">ntrunc</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">,</tt><tt class="py-op">:</tt><tt class="py-op">,</tt><tt class="py-op">:</tt><tt class="py-op">]</tt> </tt>
<a name="L1030"></a><tt class="py-lineno">1030</tt>  <tt class="py-line">    <tt class="py-name">indexm</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">indices</tt><tt class="py-op">(</tt><tt class="py-op">(</tt><tt class="py-name">ntrunc</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">,</tt><tt class="py-name">ntrunc</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">,</tt><tt class="py-op">:</tt><tt class="py-op">,</tt><tt class="py-op">:</tt><tt class="py-op">]</tt> </tt>
<a name="L1031"></a><tt class="py-lineno">1031</tt>  <tt class="py-line">    <tt class="py-name">indices</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">nonzero</tt><tt class="py-op">(</tt><tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">greater</tt><tt class="py-op">(</tt><tt class="py-name">indexn</tt><tt class="py-op">,</tt> <tt class="py-name">indexm</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">flatten</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L1032"></a><tt class="py-lineno">1032</tt>  <tt class="py-line">    <tt class="py-name">indxn</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">take</tt><tt class="py-op">(</tt><tt class="py-name">indexn</tt><tt class="py-op">.</tt><tt class="py-name">flatten</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">,</tt><tt class="py-name">indices</tt><tt class="py-op">)</tt> </tt>
<a name="L1033"></a><tt class="py-lineno">1033</tt>  <tt class="py-line">    <tt class="py-name">indxm</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">take</tt><tt class="py-op">(</tt><tt class="py-name">indexm</tt><tt class="py-op">.</tt><tt class="py-name">flatten</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">,</tt><tt class="py-name">indices</tt><tt class="py-op">)</tt> </tt>
<a name="L1034"></a><tt class="py-lineno">1034</tt>  <tt class="py-line"> </tt>
<a name="L1035"></a><tt class="py-lineno">1035</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">squeeze</tt><tt class="py-op">(</tt><tt class="py-name">indxm</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">squeeze</tt><tt class="py-op">(</tt><tt class="py-name">indxn</tt><tt class="py-op">)</tt> </tt>
</div><a name="L1036"></a><tt class="py-lineno">1036</tt>  <tt class="py-line"> </tt>
<a name="getgeodesicpts"></a><div id="getgeodesicpts-def"><a name="L1037"></a><tt class="py-lineno">1037</tt> <a class="py-toggle" href="#" id="getgeodesicpts-toggle" onclick="return toggle('getgeodesicpts');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="spharm.spharm-module.html#getgeodesicpts">getgeodesicpts</a><tt class="py-op">(</tt><tt class="py-param">m</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="getgeodesicpts-collapsed" style="display:none;" pad="++++" indent="++++"></div><div id="getgeodesicpts-expanded"><a name="L1038"></a><tt class="py-lineno">1038</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L1039"></a><tt class="py-lineno">1039</tt>  <tt class="py-line"><tt class="py-docstring"> computes the lat/lon values of the points on the surface of the sphere</tt> </tt>
<a name="L1040"></a><tt class="py-lineno">1040</tt>  <tt class="py-line"><tt class="py-docstring"> corresponding to a twenty-sided (icosahedral) geodesic.</tt> </tt>
<a name="L1041"></a><tt class="py-lineno">1041</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L1042"></a><tt class="py-lineno">1042</tt>  <tt class="py-line"><tt class="py-docstring"> @param m: the number of points on the edge of a single geodesic triangle.</tt> </tt>
<a name="L1043"></a><tt class="py-lineno">1043</tt>  <tt class="py-line"><tt class="py-docstring"> There are 10*(m-1)**2+2 total geodesic points, including the poles.</tt> </tt>
<a name="L1044"></a><tt class="py-lineno">1044</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L1045"></a><tt class="py-lineno">1045</tt>  <tt class="py-line"><tt class="py-docstring"> @return: C{B{lats, lons}} - rank 1 numpy float32 arrays containing</tt> </tt>
<a name="L1046"></a><tt class="py-lineno">1046</tt>  <tt class="py-line"><tt class="py-docstring"> the latitudes and longitudes of the geodesic points (in degrees). These</tt> </tt>
<a name="L1047"></a><tt class="py-lineno">1047</tt>  <tt class="py-line"><tt class="py-docstring"> points are nearly evenly distributed on the surface of the sphere.</tt> </tt>
<a name="L1048"></a><tt class="py-lineno">1048</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L1049"></a><tt class="py-lineno">1049</tt>  <tt class="py-line">    <tt class="py-name">x</tt><tt class="py-op">,</tt><tt class="py-name">y</tt><tt class="py-op">,</tt><tt class="py-name">z</tt> <tt class="py-op">=</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">ihgeod</tt><tt class="py-op">(</tt><tt class="py-name">m</tt><tt class="py-op">)</tt> </tt>
<a name="L1050"></a><tt class="py-lineno">1050</tt>  <tt class="py-line"><tt class="py-comment"># convert cartesian coords to lat/lon.</tt> </tt>
<a name="L1051"></a><tt class="py-lineno">1051</tt>  <tt class="py-line">    <tt class="py-name">rad2dg</tt> <tt class="py-op">=</tt> <tt class="py-number">180.</tt><tt class="py-op">/</tt><tt class="py-name">math</tt><tt class="py-op">.</tt><tt class="py-name">pi</tt> </tt>
<a name="L1052"></a><tt class="py-lineno">1052</tt>  <tt class="py-line">    <tt class="py-name">r1</tt> <tt class="py-op">=</tt> <tt class="py-name">x</tt><tt class="py-op">*</tt><tt class="py-name">x</tt><tt class="py-op">+</tt><tt class="py-name">y</tt><tt class="py-op">*</tt><tt class="py-name">y</tt> </tt>
<a name="L1053"></a><tt class="py-lineno">1053</tt>  <tt class="py-line">    <tt class="py-name">r</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">sqrt</tt><tt class="py-op">(</tt><tt class="py-name">r1</tt><tt class="py-op">+</tt><tt class="py-name">z</tt><tt class="py-op">*</tt><tt class="py-name">z</tt><tt class="py-op">)</tt> </tt>
<a name="L1054"></a><tt class="py-lineno">1054</tt>  <tt class="py-line">    <tt class="py-name">r1</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">sqrt</tt><tt class="py-op">(</tt><tt class="py-name">r1</tt><tt class="py-op">)</tt> </tt>
<a name="L1055"></a><tt class="py-lineno">1055</tt>  <tt class="py-line">    <tt class="py-name">xtmp</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">where</tt><tt class="py-op">(</tt><tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">logical_or</tt><tt class="py-op">(</tt><tt class="py-name">x</tt><tt class="py-op">,</tt><tt class="py-name">y</tt><tt class="py-op">)</tt><tt class="py-op">,</tt><tt class="py-name">x</tt><tt class="py-op">,</tt><tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">ones</tt><tt class="py-op">(</tt><tt class="py-name">x</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">,</tt><tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">float32</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L1056"></a><tt class="py-lineno">1056</tt>  <tt class="py-line">    <tt class="py-name">ztmp</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">where</tt><tt class="py-op">(</tt><tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">logical_or</tt><tt class="py-op">(</tt><tt class="py-name">r1</tt><tt class="py-op">,</tt><tt class="py-name">z</tt><tt class="py-op">)</tt><tt class="py-op">,</tt><tt class="py-name">z</tt><tt class="py-op">,</tt><tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">ones</tt><tt class="py-op">(</tt><tt class="py-name">z</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">,</tt><tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">float32</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L1057"></a><tt class="py-lineno">1057</tt>  <tt class="py-line">    <tt class="py-name">lons</tt> <tt class="py-op">=</tt> <tt class="py-name">rad2dg</tt><tt class="py-op">*</tt><tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">arctan2</tt><tt class="py-op">(</tt><tt class="py-name">y</tt><tt class="py-op">,</tt><tt class="py-name">xtmp</tt><tt class="py-op">)</tt><tt class="py-op">+</tt><tt class="py-number">180.</tt> </tt>
<a name="L1058"></a><tt class="py-lineno">1058</tt>  <tt class="py-line">    <tt class="py-name">lats</tt> <tt class="py-op">=</tt> <tt class="py-name">rad2dg</tt><tt class="py-op">*</tt><tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">arctan2</tt><tt class="py-op">(</tt><tt class="py-name">r1</tt><tt class="py-op">,</tt><tt class="py-name">ztmp</tt><tt class="py-op">)</tt><tt class="py-op">-</tt><tt class="py-number">90.</tt> </tt>
<a name="L1059"></a><tt class="py-lineno">1059</tt>  <tt class="py-line">    <tt class="py-name">lat</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">zeros</tt><tt class="py-op">(</tt><tt class="py-number">10</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">m</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">**</tt><tt class="py-number">2</tt><tt class="py-op">+</tt><tt class="py-number">2</tt><tt class="py-op">,</tt><tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">float32</tt><tt class="py-op">)</tt> </tt>
<a name="L1060"></a><tt class="py-lineno">1060</tt>  <tt class="py-line">    <tt class="py-name">lon</tt> <tt class="py-op">=</tt> <tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">zeros</tt><tt class="py-op">(</tt><tt class="py-number">10</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">m</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">**</tt><tt class="py-number">2</tt><tt class="py-op">+</tt><tt class="py-number">2</tt><tt class="py-op">,</tt><tt class="py-name">numpy</tt><tt class="py-op">.</tt><tt class="py-name">float32</tt><tt class="py-op">)</tt> </tt>
<a name="L1061"></a><tt class="py-lineno">1061</tt>  <tt class="py-line"><tt class="py-comment"># first two points are poles.</tt> </tt>
<a name="L1062"></a><tt class="py-lineno">1062</tt>  <tt class="py-line">    <tt class="py-name">lat</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-number">90</tt><tt class="py-op">;</tt> <tt class="py-name">lat</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-op">-</tt><tt class="py-number">90.</tt> </tt>
<a name="L1063"></a><tt class="py-lineno">1063</tt>  <tt class="py-line">    <tt class="py-name">lon</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-number">0.</tt><tt class="py-op">;</tt> <tt class="py-name">lon</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-number">0.</tt> </tt>
<a name="L1064"></a><tt class="py-lineno">1064</tt>  <tt class="py-line">    <tt class="py-name">lat</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">:</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">lats</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">:</tt><tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">m</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">,</tt><tt class="py-number">0</tt><tt class="py-op">:</tt><tt class="py-name">m</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">,</tt><tt class="py-op">:</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt class="py-name">flatten</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L1065"></a><tt class="py-lineno">1065</tt>  <tt class="py-line">    <tt class="py-name">lon</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">:</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">lons</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">:</tt><tt class="py-number">2</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-name">m</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">,</tt><tt class="py-number">0</tt><tt class="py-op">:</tt><tt class="py-name">m</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">,</tt><tt class="py-op">:</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt class="py-name">flatten</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L1066"></a><tt class="py-lineno">1066</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">lat</tt><tt class="py-op">,</tt><tt class="py-name">lon</tt> </tt>
</div><a name="L1067"></a><tt class="py-lineno">1067</tt>  <tt class="py-line"> </tt>
<a name="legendre"></a><div id="legendre-def"><a name="L1068"></a><tt class="py-lineno">1068</tt> <a class="py-toggle" href="#" id="legendre-toggle" onclick="return toggle('legendre');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="spharm.spharm-module.html#legendre">legendre</a><tt class="py-op">(</tt><tt class="py-param">lat</tt><tt class="py-op">,</tt><tt class="py-param">ntrunc</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="legendre-collapsed" style="display:none;" pad="++++" indent="++++"></div><div id="legendre-expanded"><a name="L1069"></a><tt class="py-lineno">1069</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L1070"></a><tt class="py-lineno">1070</tt>  <tt class="py-line"><tt class="py-docstring"> calculate associated legendre functions for triangular truncation T(ntrunc),</tt> </tt>
<a name="L1071"></a><tt class="py-lineno">1071</tt>  <tt class="py-line"><tt class="py-docstring"> at a given latitude.</tt> </tt>
<a name="L1072"></a><tt class="py-lineno">1072</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L1073"></a><tt class="py-lineno">1073</tt>  <tt class="py-line"><tt class="py-docstring"> @param lat:  the latitude (in degrees) to compute the associate legendre</tt> </tt>
<a name="L1074"></a><tt class="py-lineno">1074</tt>  <tt class="py-line"><tt class="py-docstring"> functions.</tt> </tt>
<a name="L1075"></a><tt class="py-lineno">1075</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L1076"></a><tt class="py-lineno">1076</tt>  <tt class="py-line"><tt class="py-docstring"> @param ntrunc:  the triangular truncation limit.</tt> </tt>
<a name="L1077"></a><tt class="py-lineno">1077</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L1078"></a><tt class="py-lineno">1078</tt>  <tt class="py-line"><tt class="py-docstring"> @return: C{B{pnm}} - rank 1 numpy float32 array containing the</tt> </tt>
<a name="L1079"></a><tt class="py-lineno">1079</tt>  <tt class="py-line"><tt class="py-docstring"> (C{B{ntrunc}}+1)*(C{B{ntrunc}}+2)/2 associated legendre functions at</tt> </tt>
<a name="L1080"></a><tt class="py-lineno">1080</tt>  <tt class="py-line"><tt class="py-docstring"> latitude C{B{lat}}.</tt> </tt>
<a name="L1081"></a><tt class="py-lineno">1081</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L1082"></a><tt class="py-lineno">1082</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt class="py-name">getlegfunc</tt><tt class="py-op">(</tt><tt class="py-name">lat</tt><tt class="py-op">,</tt><tt class="py-name">ntrunc</tt><tt class="py-op">)</tt> </tt>
</div><a name="L1083"></a><tt class="py-lineno">1083</tt>  <tt class="py-line"> </tt>
<a name="specintrp"></a><div id="specintrp-def"><a name="L1084"></a><tt class="py-lineno">1084</tt> <a class="py-toggle" href="#" id="specintrp-toggle" onclick="return toggle('specintrp');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="spharm.spharm-module.html#specintrp">specintrp</a><tt class="py-op">(</tt><tt class="py-param">lon</tt><tt class="py-op">,</tt><tt class="py-param">dataspec</tt><tt class="py-op">,</tt><tt class="py-param">legfuncs</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="specintrp-collapsed" style="display:none;" pad="++++" indent="++++"></div><div id="specintrp-expanded"><a name="L1085"></a><tt class="py-lineno">1085</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L1086"></a><tt class="py-lineno">1086</tt>  <tt class="py-line"><tt class="py-docstring">    spectral interpolation given spherical harmonic coefficients.</tt> </tt>
<a name="L1087"></a><tt class="py-lineno">1087</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L1088"></a><tt class="py-lineno">1088</tt>  <tt class="py-line"><tt class="py-docstring">    @param lon: longitude (in degrees) of point on a sphere to interpolate to.</tt> </tt>
<a name="L1089"></a><tt class="py-lineno">1089</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L1090"></a><tt class="py-lineno">1090</tt>  <tt class="py-line"><tt class="py-docstring">    @param dataspec:  spectral coefficients of function to interpolate.</tt> </tt>
<a name="L1091"></a><tt class="py-lineno">1091</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L1092"></a><tt class="py-lineno">1092</tt>  <tt class="py-line"><tt class="py-docstring">    @param legfuncs: associated legendre functions with same triangular</tt> </tt>
<a name="L1093"></a><tt class="py-lineno">1093</tt>  <tt class="py-line"><tt class="py-docstring">    truncation as C{B{dataspec}} (computed using L{legendre}), computed</tt> </tt>
<a name="L1094"></a><tt class="py-lineno">1094</tt>  <tt class="py-line"><tt class="py-docstring">    at latitude of interpolation point.</tt> </tt>
<a name="L1095"></a><tt class="py-lineno">1095</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L1096"></a><tt class="py-lineno">1096</tt>  <tt class="py-line"><tt class="py-docstring">    @return: C{B{ob}} - interpolated value.</tt> </tt>
<a name="L1097"></a><tt class="py-lineno">1097</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L1098"></a><tt class="py-lineno">1098</tt>  <tt class="py-line">    <tt class="py-name">ntrunc1</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-op">-</tt><tt class="py-number">1.5</tt> <tt class="py-op">+</tt> <tt class="py-number">0.5</tt><tt class="py-op">*</tt><tt class="py-name">math</tt><tt class="py-op">.</tt><tt class="py-name">sqrt</tt><tt class="py-op">(</tt><tt class="py-number">9.</tt><tt class="py-op">-</tt><tt class="py-number">8.</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-number">1.</tt><tt class="py-op">-</tt><tt class="py-name">dataspec</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L1099"></a><tt class="py-lineno">1099</tt>  <tt class="py-line">    <tt class="py-name">ntrunc2</tt> <tt class="py-op">=</tt> <tt class="py-name">int</tt><tt class="py-op">(</tt><tt class="py-op">-</tt><tt class="py-number">1.5</tt> <tt class="py-op">+</tt> <tt class="py-number">0.5</tt><tt class="py-op">*</tt><tt class="py-name">math</tt><tt class="py-op">.</tt><tt class="py-name">sqrt</tt><tt class="py-op">(</tt><tt class="py-number">9.</tt><tt class="py-op">-</tt><tt class="py-number">8.</tt><tt class="py-op">*</tt><tt class="py-op">(</tt><tt class="py-number">1.</tt><tt class="py-op">-</tt><tt class="py-name">legfuncs</tt><tt class="py-op">.</tt><tt class="py-name">shape</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L1100"></a><tt class="py-lineno">1100</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">ntrunc1</tt> <tt class="py-op">!=</tt> <tt class="py-name">ntrunc2</tt><tt class="py-op">:</tt> </tt>
<a name="L1101"></a><tt class="py-lineno">1101</tt>  <tt class="py-line">        <tt class="py-keyword">raise</tt> <tt class="py-name">ValueError</tt><tt class="py-op">(</tt><tt class="py-string">'first dimensions of dataspec and legfuncs in Spharmt.specintrp imply inconsistent spectral truncations - they must be the same!'</tt><tt class="py-op">)</tt> </tt>
<a name="L1102"></a><tt class="py-lineno">1102</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">_spherepack</tt><tt class="py-op">.</tt><tt id="link-12" class="py-name" targets="Function spharm.spharm.specintrp()=spharm.spharm-module.html#specintrp"><a title="spharm.spharm.specintrp" class="py-name" href="#" onclick="return doclink('link-12', 'specintrp', 'link-12');">specintrp</a></tt><tt class="py-op">(</tt><tt class="py-op">(</tt><tt class="py-name">math</tt><tt class="py-op">.</tt><tt class="py-name">pi</tt><tt class="py-op">/</tt><tt class="py-number">180.</tt><tt class="py-op">)</tt><tt class="py-op">*</tt><tt class="py-name">lon</tt><tt class="py-op">,</tt><tt class="py-name">ntrunc1</tt><tt class="py-op">,</tt><tt class="py-name">dataspec</tt><tt class="py-op">,</tt><tt class="py-name">legfuncs</tt><tt class="py-op">)</tt> </tt>
</div><a name="L1103"></a><tt class="py-lineno">1103</tt>  <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th bgcolor="#70b0f0" class="navbar-select"
          >&nbsp;&nbsp;&nbsp;Home&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Tue Sep  9 10:06:01 2014
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
